Skip to content

Commit 3f5fd00

Browse files
committed
comments
1 parent 5dbfdc7 commit 3f5fd00

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

src/precompile_utils.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,10 @@ static void jl_rebuild_methtables(arraylist_t *MIs, htable_t *mtables) JL_GC_DIS
418418
jl_method_instance_t *mi = (jl_method_instance_t*)MIs->items[i];
419419
jl_method_t *m = mi->def.method;
420420
// Check if the method is already in the new table, if not then insert it there
421-
OBJHASH_PIN(m);
421+
OBJHASH_PIN(m); // m is inserted as the key and the value to the hashtable
422422
void **inserted = ptrhash_bp(&ms, m);
423423
if (*inserted != HT_NOTFOUND)
424424
continue;
425-
OBJHASH_PIN(m);
426425
*inserted = (void*)m;
427426
jl_methtable_t *old_mt = jl_method_get_table(m);
428427
if ((jl_value_t *)old_mt == jl_nothing)

src/staticdata.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

694694
static 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_
10911090
done_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) {

src/staticdata_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static int type_in_worklist(jl_value_t *v, jl_query_cache *cache) JL_NOTSAFEPOIN
190190

191191
// Memoize result
192192
if (cache != NULL) {
193-
OBJHASH_PIN(v);
193+
OBJHASH_PIN(v); // v is stored as the key in htables, pin it.
194194
ptrhash_put(&cache->type_in_worklist, (void*)v, result ? (void*)v : NULL);
195195
}
196196

0 commit comments

Comments
 (0)