@@ -2618,25 +2618,21 @@ JL_DLLEXPORT jl_value_t *jl_as_global_root(jl_value_t *val, int insert)
26182618}
26192619
26202620static void jl_prepare_serialization_data (jl_array_t * mod_array , jl_array_t * newly_inferred , uint64_t worklist_key ,
2621- /* outputs */ jl_array_t * * extext_methods , jl_array_t * * new_ext_cis ,
2622- jl_array_t * * method_roots_list , jl_array_t * * ext_targets , jl_array_t * * edges )
2621+ /* outputs */ jl_array_t * * extext_methods JL_REQUIRE_ROOTED_SLOT ,
2622+ jl_array_t * * new_ext_cis JL_REQUIRE_ROOTED_SLOT ,
2623+ jl_array_t * * method_roots_list JL_REQUIRE_ROOTED_SLOT ,
2624+ jl_array_t * * edges JL_REQUIRE_ROOTED_SLOT )
26232625{
26242626 // extext_methods: [method1, ...], worklist-owned "extending external" methods added to functions owned by modules outside the worklist
2625- // ext_targets: [invokesig1, callee1, matches1, ...] non-worklist callees of worklist-owned methods
2626- // ordinary dispatch: invokesig=NULL, callee is MethodInstance
2627- // `invoke` dispatch: invokesig is signature, callee is MethodInstance
2628- // abstract call: callee is signature
2629- // edges: [caller1, ext_targets_indexes1, ...] for worklist-owned methods calling external methods
2630- assert (edges_map == NULL );
2627+ // edges: [caller1, ext_targets, ...] for worklist-owned methods calling external methods
26312628
26322629 // Save the inferred code from newly inferred, external methods
26332630 * new_ext_cis = queue_external_cis (newly_inferred );
26342631
26352632 // Collect method extensions and edges data
2636- JL_GC_PUSH1 (& edges_map );
2637- if (edges )
2638- edges_map = jl_alloc_memory_any (0 );
26392633 * extext_methods = jl_alloc_vec_any (0 );
2634+ internal_methods = jl_alloc_vec_any (0 );
2635+ JL_GC_PUSH1 (& internal_methods );
26402636 jl_collect_methtable_from_mod (jl_type_type_mt , * extext_methods );
26412637 jl_collect_methtable_from_mod (jl_nonfunction_mt , * extext_methods );
26422638 size_t i , len = jl_array_len (mod_array );
@@ -2649,18 +2645,15 @@ static void jl_prepare_serialization_data(jl_array_t *mod_array, jl_array_t *new
26492645
26502646 if (edges ) {
26512647 size_t world = jl_atomic_load_acquire (& jl_world_counter );
2652- jl_collect_missing_backedges (jl_type_type_mt );
2653- jl_collect_missing_backedges (jl_nonfunction_mt );
2654- // jl_collect_extext_methods_from_mod and jl_collect_missing_backedges also accumulate data in callers_with_edges.
2655- // Process this to extract `edges` and `ext_targets`.
2656- * ext_targets = jl_alloc_vec_any (0 );
2657- * edges = jl_alloc_vec_any (0 );
2648+ // jl_collect_extext_methods_from_mod accumulate data in callers_with_edges.
2649+ // Process this to extract `new_ext_cis` and `edges`
26582650 * method_roots_list = jl_alloc_vec_any (0 );
26592651 // Collect the new method roots for external specializations
26602652 jl_collect_new_roots (& relocatable_ext_cis , * method_roots_list , * new_ext_cis , worklist_key );
2661- jl_collect_edges (* edges , * ext_targets , * new_ext_cis , world );
2653+ * edges = jl_alloc_vec_any (0 );
2654+ jl_collect_edges (* edges , * new_ext_cis , world );
26622655 }
2663- assert ( edges_map == NULL ); // jl_collect_edges clears this when done
2656+ internal_methods = NULL ;
26642657
26652658 JL_GC_POP ();
26662659}
@@ -2669,7 +2662,7 @@ static void jl_prepare_serialization_data(jl_array_t *mod_array, jl_array_t *new
26692662static void jl_save_system_image_to_stream (ios_t * f , jl_array_t * mod_array ,
26702663 jl_array_t * worklist , jl_array_t * extext_methods ,
26712664 jl_array_t * new_ext_cis , jl_array_t * method_roots_list ,
2672- jl_array_t * ext_targets , jl_array_t * edges ) JL_GC_DISABLED
2665+ jl_array_t * edges ) JL_GC_DISABLED
26732666{
26742667 htable_new (& field_replace , 0 );
26752668 // strip metadata and IR when requested
@@ -2772,7 +2765,6 @@ static void jl_save_system_image_to_stream(ios_t *f, jl_array_t *mod_array,
27722765 }
27732766 // step 1.1: as needed, serialize the data needed for insertion into the running system
27742767 if (extext_methods ) {
2775- assert (ext_targets );
27762768 assert (edges );
27772769 // Queue method extensions
27782770 jl_queue_for_serialization (& s , extext_methods );
@@ -2781,7 +2773,6 @@ static void jl_save_system_image_to_stream(ios_t *f, jl_array_t *mod_array,
27812773 // Queue the new roots
27822774 jl_queue_for_serialization (& s , method_roots_list );
27832775 // Queue the edges
2784- jl_queue_for_serialization (& s , ext_targets );
27852776 jl_queue_for_serialization (& s , edges );
27862777 }
27872778 jl_serialize_reachable (& s );
@@ -2935,7 +2926,6 @@ static void jl_save_system_image_to_stream(ios_t *f, jl_array_t *mod_array,
29352926 jl_write_value (& s , extext_methods );
29362927 jl_write_value (& s , new_ext_cis );
29372928 jl_write_value (& s , method_roots_list );
2938- jl_write_value (& s , ext_targets );
29392929 jl_write_value (& s , edges );
29402930 }
29412931 write_uint32 (f , jl_array_len (s .link_ids_gctags ));
@@ -3020,18 +3010,18 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
30203010 }
30213011
30223012 jl_array_t * mod_array = NULL , * extext_methods = NULL , * new_ext_cis = NULL ;
3023- jl_array_t * method_roots_list = NULL , * ext_targets = NULL , * edges = NULL ;
3013+ jl_array_t * method_roots_list = NULL , * edges = NULL ;
30243014 int64_t checksumpos = 0 ;
30253015 int64_t checksumpos_ff = 0 ;
30263016 int64_t datastartpos = 0 ;
3027- JL_GC_PUSH6 (& mod_array , & extext_methods , & new_ext_cis , & method_roots_list , & ext_targets , & edges );
3017+ JL_GC_PUSH5 (& mod_array , & extext_methods , & new_ext_cis , & method_roots_list , & edges );
30283018
30293019 if (worklist ) {
30303020 mod_array = jl_get_loaded_modules (); // __toplevel__ modules loaded in this session (from Base.loaded_modules_array)
30313021 // Generate _native_data`
30323022 if (_native_data != NULL ) {
30333023 jl_prepare_serialization_data (mod_array , newly_inferred , jl_worklist_key (worklist ),
3034- & extext_methods , & new_ext_cis , NULL , NULL , NULL );
3024+ & extext_methods , & new_ext_cis , NULL , NULL );
30353025 jl_precompile_toplevel_module = (jl_module_t * )jl_array_ptr_ref (worklist , jl_array_len (worklist )- 1 );
30363026 * _native_data = jl_precompile_worklist (worklist , extext_methods , new_ext_cis );
30373027 jl_precompile_toplevel_module = NULL ;
@@ -3060,7 +3050,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
30603050 if (worklist ) {
30613051 htable_new (& relocatable_ext_cis , 0 );
30623052 jl_prepare_serialization_data (mod_array , newly_inferred , jl_worklist_key (worklist ),
3063- & extext_methods , & new_ext_cis , & method_roots_list , & ext_targets , & edges );
3053+ & extext_methods , & new_ext_cis , & method_roots_list , & edges );
30643054 if (!emit_split ) {
30653055 write_int32 (f , 0 ); // No clone_targets
30663056 write_padding (f , LLT_ALIGN (ios_pos (f ), JL_CACHE_BYTE_ALIGNMENT ) - ios_pos (f ));
@@ -3072,7 +3062,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
30723062 }
30733063 if (_native_data != NULL )
30743064 native_functions = * _native_data ;
3075- jl_save_system_image_to_stream (ff , mod_array , worklist , extext_methods , new_ext_cis , method_roots_list , ext_targets , edges );
3065+ jl_save_system_image_to_stream (ff , mod_array , worklist , extext_methods , new_ext_cis , method_roots_list , edges );
30763066 if (_native_data != NULL )
30773067 native_functions = NULL ;
30783068 if (worklist )
@@ -3162,7 +3152,7 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
31623152 /* outputs */ jl_array_t * * restored , jl_array_t * * init_order ,
31633153 jl_array_t * * extext_methods , jl_array_t * * internal_methods ,
31643154 jl_array_t * * new_ext_cis , jl_array_t * * method_roots_list ,
3165- jl_array_t * * ext_targets , jl_array_t * * edges ,
3155+ jl_array_t * * edges ,
31663156 char * * base , arraylist_t * ccallable_list , pkgcachesizes * cachesizes ) JL_GC_DISABLED
31673157{
31683158 jl_task_t * ct = jl_current_task ;
@@ -3233,7 +3223,7 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
32333223 assert (!ios_eof (f ));
32343224 s .s = f ;
32353225 uintptr_t offset_restored = 0 , offset_init_order = 0 , offset_extext_methods = 0 , offset_new_ext_cis = 0 , offset_method_roots_list = 0 ;
3236- uintptr_t offset_ext_targets = 0 , offset_edges = 0 ;
3226+ uintptr_t offset_edges = 0 ;
32373227 if (!s .incremental ) {
32383228 size_t i ;
32393229 for (i = 0 ; tags [i ] != NULL ; i ++ ) {
@@ -3266,7 +3256,6 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
32663256 offset_extext_methods = jl_read_offset (& s );
32673257 offset_new_ext_cis = jl_read_offset (& s );
32683258 offset_method_roots_list = jl_read_offset (& s );
3269- offset_ext_targets = jl_read_offset (& s );
32703259 offset_edges = jl_read_offset (& s );
32713260 }
32723261 s .buildid_depmods_idxs = depmod_to_imageidx (depmods );
@@ -3293,13 +3282,12 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
32933282 uint32_t external_fns_begin = read_uint32 (f );
32943283 jl_read_arraylist (s .s , ccallable_list ? ccallable_list : & s .ccallable_list );
32953284 if (s .incremental ) {
3296- assert (restored && init_order && extext_methods && internal_methods && new_ext_cis && method_roots_list && ext_targets && edges );
3285+ assert (restored && init_order && extext_methods && internal_methods && new_ext_cis && method_roots_list && edges );
32973286 * restored = (jl_array_t * )jl_delayed_reloc (& s , offset_restored );
32983287 * init_order = (jl_array_t * )jl_delayed_reloc (& s , offset_init_order );
32993288 * extext_methods = (jl_array_t * )jl_delayed_reloc (& s , offset_extext_methods );
33003289 * new_ext_cis = (jl_array_t * )jl_delayed_reloc (& s , offset_new_ext_cis );
33013290 * method_roots_list = (jl_array_t * )jl_delayed_reloc (& s , offset_method_roots_list );
3302- * ext_targets = (jl_array_t * )jl_delayed_reloc (& s , offset_ext_targets );
33033291 * edges = (jl_array_t * )jl_delayed_reloc (& s , offset_edges );
33043292 * internal_methods = jl_alloc_vec_any (0 );
33053293 }
@@ -3737,9 +3725,9 @@ static jl_value_t *jl_restore_package_image_from_stream(void* pkgimage_handle, i
37373725 arraylist_t ccallable_list ;
37383726
37393727 jl_value_t * restored = NULL ;
3740- jl_array_t * init_order = NULL , * extext_methods = NULL , * internal_methods = NULL , * new_ext_cis = NULL , * method_roots_list = NULL , * ext_targets = NULL , * edges = NULL ;
3728+ jl_array_t * init_order = NULL , * extext_methods = NULL , * internal_methods = NULL , * new_ext_cis = NULL , * method_roots_list = NULL , * edges = NULL ;
37413729 jl_svec_t * cachesizes_sv = NULL ;
3742- JL_GC_PUSH9 (& restored , & init_order , & extext_methods , & internal_methods , & new_ext_cis , & method_roots_list , & ext_targets , & edges , & cachesizes_sv );
3730+ JL_GC_PUSH8 (& restored , & init_order , & extext_methods , & internal_methods , & new_ext_cis , & method_roots_list , & edges , & cachesizes_sv );
37433731
37443732 { // make a permanent in-memory copy of f (excluding the header)
37453733 ios_bufmode (f , bm_none );
@@ -3764,7 +3752,7 @@ static jl_value_t *jl_restore_package_image_from_stream(void* pkgimage_handle, i
37643752 ios_static_buffer (f , sysimg , len );
37653753 pkgcachesizes cachesizes ;
37663754 jl_restore_system_image_from_stream_ (f , image , depmods , checksum , (jl_array_t * * )& restored , & init_order , & extext_methods , & internal_methods , & new_ext_cis , & method_roots_list ,
3767- & ext_targets , & edges , & base , & ccallable_list , & cachesizes );
3755+ & edges , & base , & ccallable_list , & cachesizes );
37683756 JL_SIGATOMIC_END ();
37693757
37703758 // No special processing of `new_ext_cis` is required because recaching handled it
@@ -3778,7 +3766,7 @@ static jl_value_t *jl_restore_package_image_from_stream(void* pkgimage_handle, i
37783766 // allow users to start running in this updated world
37793767 jl_atomic_store_release (& jl_world_counter , world );
37803768 // but one of those immediate users is going to be our cache updates
3781- jl_insert_backedges ((jl_array_t * )edges , (jl_array_t * )ext_targets , ( jl_array_t * ) new_ext_cis , world ); // restore external backedges (needs to be last)
3769+ jl_insert_backedges ((jl_array_t * )edges , (jl_array_t * )new_ext_cis , world ); // restore external backedges (needs to be last)
37823770 // now permit more methods to be added again
37833771 JL_UNLOCK (& world_counter_lock );
37843772 // reinit ccallables
@@ -3794,9 +3782,9 @@ static jl_value_t *jl_restore_package_image_from_stream(void* pkgimage_handle, i
37943782 jl_svecset (cachesizes_sv , 4 , jl_box_long (cachesizes .reloclist ));
37953783 jl_svecset (cachesizes_sv , 5 , jl_box_long (cachesizes .gvarlist ));
37963784 jl_svecset (cachesizes_sv , 6 , jl_box_long (cachesizes .fptrlist ));
3797- restored = (jl_value_t * )jl_svec (8 , restored , init_order , extext_methods ,
3785+ restored = (jl_value_t * )jl_svec (7 , restored , init_order , extext_methods ,
37983786 new_ext_cis ? (jl_value_t * )new_ext_cis : jl_nothing ,
3799- method_roots_list , ext_targets , edges , cachesizes_sv );
3787+ method_roots_list , edges , cachesizes_sv );
38003788 }
38013789 else {
38023790 restored = (jl_value_t * )jl_svec (2 , restored , init_order );
@@ -3811,7 +3799,7 @@ static jl_value_t *jl_restore_package_image_from_stream(void* pkgimage_handle, i
38113799static void jl_restore_system_image_from_stream (ios_t * f , jl_image_t * image , uint32_t checksum )
38123800{
38133801 JL_TIMING (LOAD_IMAGE , LOAD_Sysimg );
3814- jl_restore_system_image_from_stream_ (f , image , NULL , checksum | ((uint64_t )0xfdfcfbfa << 32 ), NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL );
3802+ jl_restore_system_image_from_stream_ (f , image , NULL , checksum | ((uint64_t )0xfdfcfbfa << 32 ), NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL );
38153803}
38163804
38173805JL_DLLEXPORT jl_value_t * jl_restore_incremental_from_buf (void * pkgimage_handle , const char * buf , jl_image_t * image , size_t sz , jl_array_t * depmods , int completeinfo , const char * pkgname , int needs_permalloc )
0 commit comments