Skip to content

Commit

Permalink
Defer globalref lookup until after module binding tables
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Oct 16, 2022
1 parent 636a945 commit e17e117
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2816,9 +2816,7 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_array_t *depmods,
jl_cache_type_((jl_datatype_t*)obj);
}
else if (jl_is_globalref(obj)) {
jl_globalref_t *r = (jl_globalref_t*)obj;
jl_binding_t *b = jl_get_binding_if_bound(r->mod, r->name);
r->bnd_cache = b && b->value ? b : NULL;
continue; // wait until all the module binding tables have been initialized
}
else if (jl_is_module(obj)) {
// rebuild the binding table for module v
Expand Down Expand Up @@ -2851,6 +2849,16 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_array_t *depmods,
jl_gc_wb(obj, *a);
}
}
// Now pick up the globalrefs
for (size_t i = 0; i < s.fixup_list.len; i++) {
uintptr_t item = (uintptr_t)s.fixup_list.items[i];
jl_value_t *obj = (jl_value_t*)(image_base + item);
if (jl_is_globalref(obj)) {
jl_globalref_t *r = (jl_globalref_t*)obj;
jl_binding_t *b = jl_get_binding_if_bound(r->mod, r->name);
r->bnd_cache = b && b->value ? b : NULL;
}
}
arraylist_free(&s.uniquing_list);
arraylist_free(&s.fixup_list);

Expand Down

0 comments on commit e17e117

Please sign in to comment.