Skip to content

Commit d444806

Browse files
committed
Adding more OBJHASH_PIN and PTRHASH_PIN and fix jl_pinned_ref_create
1 parent c38a5fa commit d444806

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

src/engine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ template<> struct llvm::DenseMapInfo<InferKey> {
2727

2828
static inline InferKey getEmptyKey() {
2929
return InferKey{FirstInfo::getEmptyKey(),
30-
jl_pinned_ref_create(jl_value_t, SecondInfo::getEmptyKey())};
30+
jl_pinned_ref_assume(jl_value_t, SecondInfo::getEmptyKey())};
3131
}
3232

3333
static inline InferKey getTombstoneKey() {
3434
return InferKey{FirstInfo::getTombstoneKey(),
35-
jl_pinned_ref_create(jl_value_t, SecondInfo::getTombstoneKey())};
35+
jl_pinned_ref_assume(jl_value_t, SecondInfo::getTombstoneKey())};
3636
}
3737

3838
static unsigned getHashValue(const InferKey& PairVal) {

src/genericmemory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ JL_DLLEXPORT jl_genericmemory_t *jl_alloc_genericmemory_unchecked(jl_ptls_t ptls
4747
else {
4848
int isaligned = 1; // jl_gc_managed_malloc is always aligned
4949
jl_gc_track_malloced_genericmemory(ptls, m, isaligned);
50+
OBJ_PIN(m);
5051
jl_genericmemory_data_owner_field(m) = (jl_value_t*)m;
5152
}
5253
// length set by codegen

src/precompile_utils.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,12 @@ static void jl_rebuild_methtables(arraylist_t* MIs, htable_t* mtables)
412412
if ((jl_value_t *)old_mt == jl_nothing)
413413
continue;
414414
jl_sym_t *name = old_mt->name;
415-
if (!ptrhash_has(mtables, old_mt))
416-
ptrhash_put(mtables, old_mt, jl_new_method_table(name, m->module));
415+
if (!ptrhash_has(mtables, old_mt)) {
416+
jl_methtable_t *new_mt = jl_new_method_table(name, m->module);
417+
OBJHASH_PIN(old_mt)
418+
OBJHASH_PIN(new_mt)
419+
ptrhash_put(mtables, old_mt, new_mt);
420+
}
417421
jl_methtable_t *mt = (jl_methtable_t*)ptrhash_get(mtables, old_mt);
418422
size_t world = jl_atomic_load_acquire(&jl_world_counter);
419423
jl_value_t * lookup = jl_methtable_lookup(mt, m->sig, world);

src/signals-mach.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ void jl_profile_thread_mach(int tid)
782782
profile_bt_data_prof[profile_bt_size_cur++].uintptr = ptls->tid + 1;
783783

784784
// store task id (never null)
785-
profile_bt_data_prof[profile_bt_size_cur++].jlvalue = (jl_value_t*)jl_atomic_load_relaxed(&ptls->current_task);
785+
jl_pinned_ref_set(profile_bt_data_prof[profile_bt_size_cur++].jlvalue, (jl_value_t*)jl_atomic_load_relaxed(&ptls->current_task));
786786

787787
// store cpu cycle clock
788788
profile_bt_data_prof[profile_bt_size_cur++].uintptr = cycleclock();

src/staticdata.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,12 +2591,16 @@ static void jl_prune_module_bindings(jl_module_t * m) JL_GC_DISABLED
25912591
void *idx = ptrhash_get(&serialization_order, bindings);
25922592
assert(idx != HT_NOTFOUND && idx != (void*)(uintptr_t)-1);
25932593
assert(serialization_queue.items[(char*)idx - 1 - (char*)HT_NOTFOUND] == bindings);
2594+
OBJHASH_PIN(bindings2)
2595+
OBJHASH_PIN(idx)
25942596
ptrhash_put(&serialization_order, bindings2, idx);
25952597
serialization_queue.items[(char*)idx - 1 - (char*)HT_NOTFOUND] = bindings2;
25962598

25972599
idx = ptrhash_get(&serialization_order, bindingkeyset);
25982600
assert(idx != HT_NOTFOUND && idx != (void*)(uintptr_t)-1);
25992601
assert(serialization_queue.items[(char*)idx - 1 - (char*)HT_NOTFOUND] == bindingkeyset);
2602+
OBJHASH_PIN(jl_atomic_load_relaxed(&bindingkeyset2))
2603+
OBJHASH_PIN(idx)
26002604
ptrhash_put(&serialization_order, jl_atomic_load_relaxed(&bindingkeyset2), idx);
26012605
serialization_queue.items[(char*)idx - 1 - (char*)HT_NOTFOUND] = jl_atomic_load_relaxed(&bindingkeyset2);
26022606
jl_atomic_store_relaxed(&m->bindings, bindings2);
@@ -2947,6 +2951,8 @@ static void jl_save_system_image_to_stream(ios_t *f, jl_array_t *mod_array,
29472951
}
29482952
else {
29492953
// replace the bits
2954+
OBJHASH_PIN(fldaddr)
2955+
OBJHASH_PIN(newval)
29502956
ptrhash_put(&bits_replace, (void*)fldaddr, newval);
29512957
// and any pointers inside
29522958
jl_datatype_t *rty = (jl_datatype_t*)jl_typeof(newval);
@@ -3006,6 +3012,7 @@ static void jl_save_system_image_to_stream(ios_t *f, jl_array_t *mod_array,
30063012
htable_new(&fptr_to_id, sizeof(id_to_fptrs) / sizeof(*id_to_fptrs));
30073013
uintptr_t i;
30083014
for (i = 0; id_to_fptrs[i] != NULL; i++) {
3015+
PTRHASH_PIN(id_to_fptrs[i])
30093016
ptrhash_put(&fptr_to_id, (void*)(uintptr_t)id_to_fptrs[i], (void*)(i + 2));
30103017
}
30113018
htable_new(&serialization_order, 25000);

0 commit comments

Comments
 (0)