Skip to content

Commit a3b193c

Browse files
JeffBezansonKristofferC
authored andcommitted
add trimming of new usings_backedges and scanned_methods fields (#57879)
(cherry picked from commit 8fd3fb1)
1 parent 4bf5a26 commit a3b193c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/staticdata.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,14 @@ static void jl_queue_module_for_serialization(jl_serializer_state *s, jl_module_
851851
jl_queue_for_serialization(s, module_usings_getmod(m, i));
852852
}
853853

854-
jl_queue_for_serialization(s, m->usings_backedges);
855-
jl_queue_for_serialization(s, m->scanned_methods);
854+
if (jl_options.trim || jl_options.strip_ir) {
855+
record_field_change((jl_value_t**)&m->usings_backedges, jl_nothing);
856+
record_field_change((jl_value_t**)&m->scanned_methods, jl_nothing);
857+
}
858+
else {
859+
jl_queue_for_serialization(s, m->usings_backedges);
860+
jl_queue_for_serialization(s, m->scanned_methods);
861+
}
856862
}
857863

858864
// Anything that requires uniquing or fixing during deserialization needs to be "toplevel"
@@ -1367,10 +1373,10 @@ static void jl_write_module(jl_serializer_state *s, uintptr_t item, jl_module_t
13671373
newm->line = 0;
13681374
newm->usings_backedges = NULL;
13691375
arraylist_push(&s->relocs_list, (void*)(reloc_offset + offsetof(jl_module_t, usings_backedges)));
1370-
arraylist_push(&s->relocs_list, (void*)backref_id(s, m->usings_backedges, s->link_ids_relocs));
1376+
arraylist_push(&s->relocs_list, (void*)backref_id(s, get_replaceable_field(&m->usings_backedges, 1), s->link_ids_relocs));
13711377
newm->scanned_methods = NULL;
13721378
arraylist_push(&s->relocs_list, (void*)(reloc_offset + offsetof(jl_module_t, scanned_methods)));
1373-
arraylist_push(&s->relocs_list, (void*)backref_id(s, m->scanned_methods, s->link_ids_relocs));
1379+
arraylist_push(&s->relocs_list, (void*)backref_id(s, get_replaceable_field(&m->scanned_methods, 1), s->link_ids_relocs));
13741380

13751381
// After reload, everything that has happened in this process happened semantically at
13761382
// (for .incremental) or before jl_require_world, so reset this flag.
@@ -3635,7 +3641,7 @@ static int jl_validate_binding_partition(jl_binding_t *b, jl_binding_partition_t
36353641
jl_sym_t *name = b->globalref->name;
36363642
JL_LOCK(&mod->lock);
36373643
jl_atomic_store_release(&mod->export_set_changed_since_require_world, 1);
3638-
if (mod->usings_backedges) {
3644+
if (mod->usings_backedges != jl_nothing) {
36393645
for (size_t i = 0; i < jl_array_len(mod->usings_backedges); i++) {
36403646
jl_module_t *edge = (jl_module_t*)jl_array_ptr_ref(mod->usings_backedges, i);
36413647
jl_binding_t *importee = jl_get_module_binding(edge, name, 0);

test/trimming/trimming.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let exe_suffix = splitext(Base.julia_exename())[2]
44

55
hello_exe = joinpath(@__DIR__, "hello" * exe_suffix)
66
@test readchomp(`$hello_exe`) == "Hello, world!"
7-
@test filesize(hello_exe) < 20_000_000
7+
@test filesize(hello_exe) < 2000000
88

99
basic_jll_exe = joinpath(@__DIR__, "basic_jll" * exe_suffix)
1010
lines = split(readchomp(`$basic_jll_exe`), "\n")

0 commit comments

Comments
 (0)