Skip to content

Commit 0ec704e

Browse files
authored
staticdata: set method.nroots_sysimg in jl_write_values (#48875)
This ensures that the value gets set after all possible compilation has occurred.
1 parent 5c3a2e2 commit 0ec704e

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/staticdata.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,8 @@ static void jl_write_values(jl_serializer_state *s) JL_GC_DISABLED
13461346
else
13471347
arraylist_push(&s->fixup_objs, (void*)reloc_offset);
13481348
newm->primary_world = ~(size_t)0;
1349+
} else {
1350+
newm->nroots_sysimg = m->roots ? jl_array_len(m->roots) : 0;
13491351
}
13501352
if (m->ccallable)
13511353
arraylist_push(&s->ccallable_list, (void*)reloc_offset);
@@ -2146,28 +2148,6 @@ static void jl_strip_all_codeinfos(void)
21462148
jl_foreach_reachable_mtable(strip_all_codeinfos_, NULL);
21472149
}
21482150

2149-
// Method roots created during sysimg construction are exempted from
2150-
// triggering non-relocatability of compressed CodeInfos.
2151-
// Set the number of such roots in each method when the sysimg is
2152-
// serialized.
2153-
// TODO: move this to `jl_write_values`
2154-
static int set_nroots_sysimg__(jl_typemap_entry_t *def, void *_env)
2155-
{
2156-
jl_method_t *m = def->func.method;
2157-
m->nroots_sysimg = m->roots ? jl_array_len(m->roots) : 0;
2158-
return 1;
2159-
}
2160-
2161-
static int set_nroots_sysimg_(jl_methtable_t *mt, void *_env)
2162-
{
2163-
return jl_typemap_visitor(mt->defs, set_nroots_sysimg__, NULL);
2164-
}
2165-
2166-
static void jl_set_nroots_sysimg(void)
2167-
{
2168-
jl_foreach_reachable_mtable(set_nroots_sysimg_, NULL);
2169-
}
2170-
21712151
// --- entry points ---
21722152

21732153
jl_array_t *jl_global_roots_table;
@@ -2271,8 +2251,6 @@ static void jl_save_system_image_to_stream(ios_t *f, jl_array_t *mod_array,
22712251
// strip metadata and IR when requested
22722252
if (jl_options.strip_metadata || jl_options.strip_ir)
22732253
jl_strip_all_codeinfos();
2274-
if (worklist == NULL)
2275-
jl_set_nroots_sysimg();
22762254

22772255
int en = jl_gc_enable(0);
22782256
nsym_tag = 0;

0 commit comments

Comments
 (0)