Skip to content

Commit cc0c149

Browse files
committed
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 <tim.holy@gmail.com> (cherry picked from commit 8e3e970)
1 parent 2b4d547 commit cc0c149

File tree

6 files changed

+136
-89
lines changed

6 files changed

+136
-89
lines changed

src/codegen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4230,7 +4230,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, const
42304230
bool cache_valid = ctx.use_cache;
42314231
bool external = false;
42324232
if (ctx.external_linkage) {
4233-
if (jl_object_in_image((jl_value_t*)codeinst)) {
4233+
if (0 && jl_object_in_image((jl_value_t*)codeinst)) {
42344234
// Target is present in another pkgimage
42354235
cache_valid = true;
42364236
external = true;
@@ -5597,7 +5597,7 @@ static Function *emit_tojlinvoke(jl_code_instance_t *codeinst, Module *M, jl_cod
55975597

55985598
bool cache_valid = params.cache;
55995599
if (params.external_linkage) {
5600-
if (jl_object_in_image((jl_value_t*)codeinst)) {
5600+
if (0 && jl_object_in_image((jl_value_t*)codeinst)) {
56015601
// Target is present in another pkgimage
56025602
cache_valid = true;
56035603
}
@@ -8503,7 +8503,7 @@ void jl_compile_workqueue(
85038503
auto invoke = jl_atomic_load_relaxed(&codeinst->invoke);
85048504
bool cache_valid = params.cache;
85058505
if (params.external_linkage) {
8506-
cache_valid = jl_object_in_image((jl_value_t*)codeinst);
8506+
cache_valid = 0 && jl_object_in_image((jl_value_t*)codeinst);
85078507
}
85088508
// 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.
85098509
if (cache_valid && invoke != NULL) {

src/gc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,8 +3022,6 @@ static void mark_roots(jl_gc_mark_cache_t *gc_cache, jl_gc_mark_sp_t *sp)
30223022
}
30233023
if (_jl_debug_method_invalidation != NULL)
30243024
gc_mark_queue_obj(gc_cache, sp, _jl_debug_method_invalidation);
3025-
if (jl_build_ids != NULL)
3026-
gc_mark_queue_obj(gc_cache, sp, jl_build_ids);
30273025

30283026
// constants
30293027
gc_mark_queue_obj(gc_cache, sp, jl_emptytuple_type);

src/jl_exported_data.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@
127127
XX(jl_voidpointer_type) \
128128
XX(jl_void_type) \
129129
XX(jl_weakref_type) \
130-
XX(jl_build_ids) \
131-
XX(jl_linkage_blobs) \
132130

133131
// Data symbols that are defined inside the public libjulia
134132
#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;
@@ -956,10 +955,7 @@ static inline void jl_set_gc_and_wait(void)
956955
// Query if a Julia object is if a permalloc region (due to part of a sys- pkg-image)
957956
STATIC_INLINE size_t n_linkage_blobs(void) JL_NOTSAFEPOINT
958957
{
959-
if (!jl_build_ids)
960-
return 0;
961-
assert(jl_is_array(jl_build_ids));
962-
return jl_array_len(jl_build_ids);
958+
return jl_image_relocs.len;
963959
}
964960

965961
// TODO: Makes this a binary search

0 commit comments

Comments
 (0)