@@ -664,7 +664,7 @@ static int needs_recaching(jl_value_t *v) JL_NOTSAFEPOINT
664
664
665
665
static int needs_uniquing (jl_value_t * v ) JL_NOTSAFEPOINT
666
666
{
667
- assert (!jl_object_in_image (v ));
667
+ assert (!jl_object_in_image (v ) || jl_is_code_instance ( v ) );
668
668
return caching_tag (v ) == 1 ;
669
669
}
670
670
@@ -1017,8 +1017,8 @@ static uintptr_t add_external_linkage(jl_serializer_state *s, jl_value_t *v, jl_
1017
1017
// Return the integer `id` for `v`. Generically this is looked up in `serialization_order`,
1018
1018
// but symbols, small integers, and a couple of special items (`nothing` and the root Task)
1019
1019
// have special handling.
1020
- #define backref_id (s , v , link_ids ) _backref_id(s, (jl_value_t*)(v), link_ids)
1021
- static uintptr_t _backref_id (jl_serializer_state * s , jl_value_t * v , jl_array_t * link_ids ) JL_NOTSAFEPOINT
1020
+ #define backref_id (s , v , link_ids ) _backref_id(s, (jl_value_t*)(v), link_ids, /* allow_copies */ 1 )
1021
+ static uintptr_t _backref_id (jl_serializer_state * s , jl_value_t * v , jl_array_t * link_ids , int allow_copies ) JL_NOTSAFEPOINT
1022
1022
{
1023
1023
assert (v != NULL && "cannot get backref to NULL object" );
1024
1024
void * idx = HT_NOTFOUND ;
@@ -1055,10 +1055,18 @@ static uintptr_t _backref_id(jl_serializer_state *s, jl_value_t *v, jl_array_t *
1055
1055
uint8_t u8 = * (uint8_t * )v ;
1056
1056
return ((uintptr_t )TagRef << RELOC_TAG_OFFSET ) + u8 + 2 + NBOX_C + NBOX_C ;
1057
1057
}
1058
+ if (!allow_copies ) {
1059
+ if (s -> incremental && jl_object_in_image (v )) {
1060
+ assert (link_ids );
1061
+ uintptr_t item = add_external_linkage (s , v , link_ids );
1062
+ assert (item && "no external linkage identified" );
1063
+ return item ;
1064
+ }
1065
+ }
1058
1066
if (idx == HT_NOTFOUND ) {
1059
1067
idx = ptrhash_get (& serialization_order , v );
1060
1068
if (idx == HT_NOTFOUND ) {
1061
- if (s -> incremental && jl_object_in_image (v )) {
1069
+ if (allow_copies && s -> incremental && jl_object_in_image (v )) {
1062
1070
assert (link_ids );
1063
1071
uintptr_t item = add_external_linkage (s , v , link_ids );
1064
1072
assert (item && "no external linkage identified" );
@@ -1205,7 +1213,7 @@ static void jl_write_values(jl_serializer_state *s) JL_GC_DISABLED
1205
1213
for (size_t item = 0 ; item < l ; item ++ ) {
1206
1214
jl_value_t * v = (jl_value_t * )serialization_queue .items [item ]; // the object
1207
1215
JL_GC_PROMISE_ROOTED (v );
1208
- assert (!(s -> incremental && jl_object_in_image (v )));
1216
+ assert (!(s -> incremental && jl_object_in_image (v ) && ! jl_is_code_instance ( v ) ));
1209
1217
jl_datatype_t * t = (jl_datatype_t * )jl_typeof (v );
1210
1218
assert ((t -> instance == NULL || t -> instance == v ) && "detected singleton construction corruption" );
1211
1219
ios_t * f = s -> s ;
@@ -2076,7 +2084,7 @@ static uint32_t write_gvars(jl_serializer_state *s, arraylist_t *globals, arrayl
2076
2084
for (size_t i = 0 ; i < external_fns -> len ; i ++ ) {
2077
2085
jl_code_instance_t * ci = (jl_code_instance_t * )external_fns -> items [i ];
2078
2086
assert (ci && (jl_atomic_load_relaxed (& ci -> specsigflags ) & 0b001 ));
2079
- uintptr_t item = backref_id (s , (void * )ci , s -> link_ids_external_fnvars );
2087
+ uintptr_t item = _backref_id (s , (jl_value_t * )ci , s -> link_ids_external_fnvars , /* allow_copies */ 0 );
2080
2088
uintptr_t reloc = get_reloc_for_item (item , 0 );
2081
2089
write_reloc_t (s -> gvar_record , reloc );
2082
2090
}
0 commit comments