@@ -18,26 +18,24 @@ struct ReservationInfo {
1818
1919struct InferKey {
2020 jl_method_instance_t *mi = nullptr ;
21- jl_pinned_ref ( jl_value_t ) owner = jl_pinned_ref_assume( jl_value_t , nullptr ) ;
21+ JL_ROOT jl_value_t * owner = nullptr ;
2222};
2323
2424template <> struct llvm ::DenseMapInfo<InferKey> {
2525 using FirstInfo = DenseMapInfo<jl_method_instance_t *>;
2626 using SecondInfo = DenseMapInfo<jl_value_t *>;
2727
2828 static inline InferKey getEmptyKey () {
29- return InferKey{FirstInfo::getEmptyKey (),
30- jl_pinned_ref_assume (jl_value_t , SecondInfo::getEmptyKey ())};
29+ return InferKey{FirstInfo::getEmptyKey (), SecondInfo::getEmptyKey ()};
3130 }
3231
3332 static inline InferKey getTombstoneKey () {
34- return InferKey{FirstInfo::getTombstoneKey (),
35- jl_pinned_ref_assume (jl_value_t , SecondInfo::getTombstoneKey ())};
33+ return InferKey{FirstInfo::getTombstoneKey (), SecondInfo::getTombstoneKey ()};
3634 }
3735
3836 static unsigned getHashValue (const InferKey& PairVal) {
3937 return detail::combineHashValue (FirstInfo::getHashValue (PairVal.mi ),
40- SecondInfo::getHashValue (jl_pinned_ref_get ( PairVal.owner ) ));
38+ SecondInfo::getHashValue (PairVal.owner ));
4139 }
4240
4341 static bool isEqual (const InferKey &LHS, const InferKey &RHS) {
@@ -66,22 +64,26 @@ jl_code_instance_t *jl_engine_reserve(jl_method_instance_t *m, jl_value_t *owner
6664 auto tid = jl_atomic_load_relaxed (&ct->tid );
6765 if (([tid, m, owner, ci] () -> bool { // necessary scope block / lambda for unique_lock
6866 jl_unique_gcsafe_lock lock (engine_lock);
69- InferKey key{m, jl_pinned_ref_create (jl_value_t , owner)};
67+ arraylist_push (&gc_pinned_objects, owner);
68+ InferKey key{m, owner};
7069 if ((signed )Awaiting.size () < tid + 1 )
7170 Awaiting.resize (tid + 1 );
7271 while (1 ) {
7372 auto record = Reservations.find (key);
7473 if (record == Reservations.end ()) {
7574 Reservations[key] = ReservationInfo{tid, ci};
75+ arraylist_pop (&gc_pinned_objects);
7676 return false ;
7777 }
7878 // before waiting, need to run deadlock/cycle detection
7979 // there is a cycle if the thread holding our lease is blocked
8080 // and waiting for (transitively) any lease that is held by this thread
8181 auto wait_tid = record->second .tid ;
8282 while (1 ) {
83- if (wait_tid == tid)
83+ if (wait_tid == tid) {
84+ arraylist_pop (&gc_pinned_objects);
8485 return true ;
86+ }
8587 if ((signed )Awaiting.size () <= wait_tid)
8688 break ; // no cycle, since it is running (and this should be unreachable)
8789 auto key2 = Awaiting[wait_tid];
@@ -97,6 +99,7 @@ jl_code_instance_t *jl_engine_reserve(jl_method_instance_t *m, jl_value_t *owner
9799 lock.wait (engine_wait);
98100 Awaiting[tid] = InferKey{};
99101 }
102+ arraylist_pop (&gc_pinned_objects);
100103 })())
101104 ct->ptls ->engine_nqueued --;
102105 JL_GC_POP ();
@@ -106,7 +109,7 @@ jl_code_instance_t *jl_engine_reserve(jl_method_instance_t *m, jl_value_t *owner
106109int jl_engine_hasreserved (jl_method_instance_t *m, jl_value_t *owner)
107110{
108111 jl_task_t *ct = jl_current_task;
109- InferKey key = {m, jl_pinned_ref_create ( jl_value_t , owner) };
112+ InferKey key = {m, owner};
110113 std::unique_lock lock (engine_lock);
111114 auto record = Reservations.find (key);
112115 return record != Reservations.end () && record->second .tid == jl_atomic_load_relaxed (&ct->tid );
@@ -139,7 +142,7 @@ void jl_engine_fulfill(jl_code_instance_t *ci, jl_code_info_t *src)
139142{
140143 jl_task_t *ct = jl_current_task;
141144 std::unique_lock lock (engine_lock);
142- auto record = Reservations.find (InferKey{jl_get_ci_mi (ci), jl_pinned_ref_create ( jl_value_t , ci->owner ) });
145+ auto record = Reservations.find (InferKey{jl_get_ci_mi (ci), ci->owner });
143146 if (record == Reservations.end () || record->second .ci != ci)
144147 return ;
145148 assert (jl_atomic_load_relaxed (&ct->tid ) == record->second .tid );
0 commit comments