Skip to content

Commit 8e3e970

Browse files
vtjnashtimholy
andauthored
staticdata: encode link_id in tagged linkage (#48673)
On 64-bit, we have enough space to encode (1) the tag, (2) the `depmods` index, and (3) the offset all in a single 64-bit pointer field. This means we don't need the external `link_id` arrays, which reduces the size of many pkgimages by ~5%. On 32-bit, we don't have enough bits to implement this strategy. However, most linkages seem to be against the sysimage, and so by giving that a separate tag we can achieve similar compression because the `link_id` lists will be much shorter. Co-authored-by: Tim Holy <[email protected]>
1 parent 892cd4f commit 8e3e970

File tree

6 files changed

+138
-88
lines changed

6 files changed

+138
-88
lines changed

src/codegen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4251,7 +4251,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, const
42514251
bool cache_valid = ctx.use_cache;
42524252
bool external = false;
42534253
if (ctx.external_linkage) {
4254-
if (jl_object_in_image((jl_value_t*)codeinst)) {
4254+
if (0 && jl_object_in_image((jl_value_t*)codeinst)) {
42554255
// Target is present in another pkgimage
42564256
cache_valid = true;
42574257
external = true;
@@ -5617,7 +5617,7 @@ static Function *emit_tojlinvoke(jl_code_instance_t *codeinst, Module *M, jl_cod
56175617

56185618
bool cache_valid = params.cache;
56195619
if (params.external_linkage) {
5620-
if (jl_object_in_image((jl_value_t*)codeinst)) {
5620+
if (0 && jl_object_in_image((jl_value_t*)codeinst)) {
56215621
// Target is present in another pkgimage
56225622
cache_valid = true;
56235623
}
@@ -8529,7 +8529,7 @@ void jl_compile_workqueue(
85298529
auto invoke = jl_atomic_load_relaxed(&codeinst->invoke);
85308530
bool cache_valid = params.cache;
85318531
if (params.external_linkage) {
8532-
cache_valid = jl_object_in_image((jl_value_t*)codeinst);
8532+
cache_valid = 0 && jl_object_in_image((jl_value_t*)codeinst);
85338533
}
85348534
// WARNING: isspecsig is protected by the codegen-lock. If that lock is removed, then the isspecsig load needs to be properly atomically sequenced with this.
85358535
if (cache_valid && invoke != NULL) {

src/gc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,7 @@ STATIC_INLINE void gc_mark_array8(jl_ptls_t ptls, jl_value_t *ary8_parent, jl_va
19851985
jl_gc_markqueue_t *mq = &ptls->mark_queue;
19861986
jl_value_t *new_obj;
19871987
size_t elsize = ((jl_array_t *)ary8_parent)->elsize / sizeof(jl_value_t *);
1988+
assert(elsize > 0);
19881989
// Decide whether need to chunk ary8
19891990
size_t nrefs = (ary8_end - ary8_begin) / elsize;
19901991
if (nrefs > MAX_REFS_AT_ONCE) {
@@ -2016,6 +2017,7 @@ STATIC_INLINE void gc_mark_array16(jl_ptls_t ptls, jl_value_t *ary16_parent, jl_
20162017
jl_gc_markqueue_t *mq = &ptls->mark_queue;
20172018
jl_value_t *new_obj;
20182019
size_t elsize = ((jl_array_t *)ary16_parent)->elsize / sizeof(jl_value_t *);
2020+
assert(elsize > 0);
20192021
// Decide whether need to chunk ary16
20202022
size_t nrefs = (ary16_end - ary16_begin) / elsize;
20212023
if (nrefs > MAX_REFS_AT_ONCE) {
@@ -2668,7 +2670,6 @@ static void gc_mark_roots(jl_gc_markqueue_t *mq)
26682670
}
26692671
gc_try_claim_and_push(mq, jl_all_methods, NULL);
26702672
gc_try_claim_and_push(mq, _jl_debug_method_invalidation, NULL);
2671-
gc_try_claim_and_push(mq, jl_build_ids, NULL);
26722673
// constants
26732674
gc_try_claim_and_push(mq, jl_emptytuple_type, NULL);
26742675
gc_try_claim_and_push(mq, cmpswap_names, NULL);

src/jl_exported_data.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@
126126
XX(jl_voidpointer_type) \
127127
XX(jl_void_type) \
128128
XX(jl_weakref_type) \
129-
XX(jl_build_ids) \
130-
XX(jl_linkage_blobs) \
131129

132130
// Data symbols that are defined inside the public libjulia
133131
#define JL_EXPORTED_DATA_SYMBOLS(XX) \

src/julia_internal.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,8 @@ extern tracer_cb jl_newmeth_tracer;
313313
void jl_call_tracer(tracer_cb callback, jl_value_t *tracee);
314314
void print_func_loc(JL_STREAM *s, jl_method_t *m);
315315
extern jl_array_t *_jl_debug_method_invalidation JL_GLOBALLY_ROOTED;
316-
extern arraylist_t jl_linkage_blobs; // external linkage: sysimg/pkgimages
317-
extern jl_array_t *jl_build_ids JL_GLOBALLY_ROOTED; // external linkage: corresponding build_ids
318-
extern arraylist_t jl_image_relocs; // external linkage: sysimg/pkgimages
316+
JL_DLLEXPORT extern arraylist_t jl_linkage_blobs; // external linkage: sysimg/pkgimages
317+
JL_DLLEXPORT extern arraylist_t jl_image_relocs; // external linkage: sysimg/pkgimages
319318

320319
extern JL_DLLEXPORT size_t jl_page_size;
321320
extern jl_function_t *jl_typeinf_func JL_GLOBALLY_ROOTED;
@@ -951,10 +950,7 @@ static inline void jl_set_gc_and_wait(void)
951950
// Query if a Julia object is if a permalloc region (due to part of a sys- pkg-image)
952951
STATIC_INLINE size_t n_linkage_blobs(void) JL_NOTSAFEPOINT
953952
{
954-
if (!jl_build_ids)
955-
return 0;
956-
assert(jl_is_array(jl_build_ids));
957-
return jl_array_len(jl_build_ids);
953+
return jl_image_relocs.len;
958954
}
959955

960956
// TODO: Makes this a binary search

0 commit comments

Comments
 (0)