@@ -677,11 +677,11 @@ static jl_value_t *get_replaceable_field(jl_value_t **addr, int mutabl) JL_GC_DI
677677 if (fld == HT_NOTFOUND ) {
678678 fld = * addr ;
679679 if (mutabl && fld && jl_is_cpointer_type (jl_typeof (fld )) && jl_unbox_voidpointer (fld ) != NULL && jl_unbox_voidpointer (fld ) != (void * )(uintptr_t )-1 ) {
680- void * * nullval = ptrhash_bp (& nullptrs , (void * )jl_typeof (fld ));
680+ void * * nullval = ptrhash_bp (& nullptrs , (void * )jl_typeof (fld )); // jl_typeof(fld) is nonmoving, no need to pin it
681681 if (* nullval == HT_NOTFOUND ) {
682682 void * C_NULL = NULL ;
683683 jl_value_t * new_fld = jl_new_bits (jl_typeof (fld ), & C_NULL );
684- OBJHASH_PIN (new_fld );
684+ OBJHASH_PIN (new_fld ); // new_fld is stored in htables, pin it.
685685 * nullval = (void * )new_fld ;
686686 }
687687 fld = (jl_value_t * )* nullval ;
@@ -693,7 +693,6 @@ static jl_value_t *get_replaceable_field(jl_value_t **addr, int mutabl) JL_GC_DI
693693
694694static uintptr_t jl_fptr_id (void * fptr )
695695{
696- PTRHASH_PIN (fptr );
697696 void * * pbp = ptrhash_bp (& fptr_to_id , fptr );
698697 if (* pbp == HT_NOTFOUND || fptr == NULL )
699698 return 0 ;
@@ -963,7 +962,7 @@ static void jl_insert_into_serialization_queue(jl_serializer_state *s, jl_value_
963962 if (jl_object_in_image ((jl_value_t * )def )) {
964963 void * * pfound = ptrhash_bp (& s -> method_roots_index , def );
965964 if (* pfound == HT_NOTFOUND ) {
966- OBJHASH_PIN (def );
965+ OBJHASH_PIN (def ); // def is stored in htables as both key and value, pin it.
967966 * pfound = def ;
968967 size_t nwithkey = nroots_with_key (def , s -> worklist_key );
969968 if (nwithkey ) {
@@ -1091,13 +1090,13 @@ static void jl_insert_into_serialization_queue(jl_serializer_state *s, jl_value_
10911090done_fields : ;
10921091
10931092 // We've encountered an item we need to cache
1094- OBJHASH_PIN (v );
1093+ OBJHASH_PIN (v ); // v is stored in htables as the key, pin it.
10951094 void * * bp = ptrhash_bp (& serialization_order , v );
10961095 assert (* bp == (void * )(uintptr_t )-2 );
10971096 arraylist_push (& serialization_queue , (void * ) v );
10981097 size_t idx = serialization_queue .len - 1 ;
10991098 assert (serialization_queue .len < ((uintptr_t )1 << RELOC_TAG_OFFSET ) && "too many items to serialize" );
1100- * bp = to_seroder_entry (idx );
1099+ * bp = to_seroder_entry (idx ); // the entry that gets stored is not an object reference, we don't need to pin it for htables.
11011100
11021101 // DataType is very unusual, in that some of the fields need to be pre-order, and some
11031102 // (notably super) must not be (even if `jl_queue_for_serialization_` would otherwise
@@ -1153,7 +1152,7 @@ static void jl_queue_for_serialization_(jl_serializer_state *s, jl_value_t *v, i
11531152 immediate = 1 ;
11541153 }
11551154
1156- OBJHASH_PIN (v );
1155+ OBJHASH_PIN (v ); // v is stoored as the key in htables, pin it. The value that gets stored later is not an object reference.
11571156 void * * bp = ptrhash_bp (& serialization_order , v );
11581157 assert (!immediate || * bp != (void * )(uintptr_t )-2 );
11591158 if (* bp == HT_NOTFOUND )
@@ -1187,7 +1186,7 @@ static void jl_serialize_reachable(jl_serializer_state *s) JL_GC_DISABLED
11871186 }
11881187 prevlen = -- object_worklist .len ;
11891188 jl_value_t * v = (jl_value_t * )object_worklist .items [prevlen ];
1190- OBJHASH_PIN (v );
1189+ OBJHASH_PIN (v ); // v is stoored as the key in htables, pin it. The value that gets stored later is not an object reference.
11911190 void * * bp = ptrhash_bp (& serialization_order , (void * )v );
11921191 assert (* bp != HT_NOTFOUND && * bp != (void * )(uintptr_t )-2 );
11931192 if (* bp == (void * )(uintptr_t )-1 ) { // might have been eagerly handled for post-order while in the lazy pre-order queue
@@ -1262,7 +1261,7 @@ static uintptr_t _backref_id(jl_serializer_state *s, jl_value_t *v, jl_array_t *
12621261{
12631262 assert (v != NULL && "cannot get backref to NULL object" );
12641263 if (jl_is_symbol (v )) {
1265- OBJHASH_PIN (v );
1264+ OBJHASH_PIN (v ); // v is stoored as the key in htables, pin it. The value that gets stored later is not an object reference.
12661265 void * * pidx = ptrhash_bp (& symbol_table , v );
12671266 void * idx = * pidx ;
12681267 if (idx == HT_NOTFOUND ) {
0 commit comments