@@ -47,7 +47,7 @@ static int eq_bindings(jl_binding_partition_t *owner, jl_binding_t *alias, size_
47
47
48
48
// find a binding from a module's `usings` list
49
49
void jl_check_new_binding_implicit (
50
- jl_binding_partition_t * new_bpart JL_MAYBE_UNROOTED , jl_binding_t * b , modstack_t * st , size_t world )
50
+ jl_binding_partition_t * new_bpart , jl_binding_t * b , modstack_t * st , size_t world )
51
51
{
52
52
modstack_t top = { b , st };
53
53
modstack_t * tmp = st ;
@@ -59,7 +59,6 @@ void jl_check_new_binding_implicit(
59
59
}
60
60
}
61
61
62
- JL_GC_PUSH1 (& new_bpart );
63
62
jl_module_t * m = b -> globalref -> mod ;
64
63
jl_sym_t * var = b -> globalref -> name ;
65
64
@@ -164,31 +163,33 @@ void jl_check_new_binding_implicit(
164
163
new_bpart -> kind = guard_kind ;
165
164
new_bpart -> restriction = NULL ;
166
165
}
167
- JL_GC_POP ();
168
- return ;
169
166
}
170
167
171
168
JL_DLLEXPORT jl_binding_partition_t * jl_maybe_reresolve_implicit (jl_binding_t * b , size_t new_max_world )
172
169
{
173
170
jl_binding_partition_t * new_bpart = new_binding_partition ();
174
171
jl_binding_partition_t * bpart = jl_atomic_load_acquire (& b -> partitions );
175
172
assert (bpart );
173
+ JL_GC_PUSH1 (& new_bpart );
176
174
while (1 ) {
177
175
jl_atomic_store_relaxed (& new_bpart -> next , bpart );
178
176
jl_gc_wb (new_bpart , bpart );
179
177
jl_check_new_binding_implicit (new_bpart , b , NULL , new_max_world + 1 );
180
- JL_GC_PROMISE_ROOTED (new_bpart ); // TODO: Analyzer doesn't understand MAYBE_UNROOTED properly
181
178
if (bpart -> kind & PARTITION_FLAG_EXPORTED )
182
179
new_bpart -> kind |= PARTITION_FLAG_EXPORTED ;
183
- if (new_bpart -> kind == bpart -> kind && new_bpart -> restriction == bpart -> restriction )
180
+ if (new_bpart -> kind == bpart -> kind && new_bpart -> restriction == bpart -> restriction ) {
181
+ JL_GC_POP ();
184
182
return bpart ;
183
+ }
185
184
// Resolution changed, insert the new partition
186
185
size_t expected_max_world = ~(size_t )0 ;
187
186
if (jl_atomic_cmpswap (& bpart -> max_world , & expected_max_world , new_max_world ) &&
188
- jl_atomic_cmpswap (& b -> partitions , & bpart , new_bpart ))
189
- break ;
187
+ jl_atomic_cmpswap (& b -> partitions , & bpart , new_bpart )) {
188
+ jl_gc_wb (b , new_bpart );
189
+ JL_GC_POP ();
190
+ return new_bpart ;
191
+ }
190
192
}
191
- return new_bpart ;
192
193
}
193
194
194
195
STATIC_INLINE jl_binding_partition_t * jl_get_binding_partition_ (jl_binding_t * b JL_PROPAGATES_ROOT , jl_value_t * parent , _Atomic (jl_binding_partition_t * )* insert , size_t world , modstack_t * st ) JL_GLOBALLY_ROOTED
@@ -197,28 +198,31 @@ STATIC_INLINE jl_binding_partition_t *jl_get_binding_partition_(jl_binding_t *b
197
198
jl_binding_partition_t * bpart = jl_atomic_load_relaxed (insert );
198
199
size_t max_world = (size_t )-1 ;
199
200
jl_binding_partition_t * new_bpart = NULL ;
201
+ JL_GC_PUSH1 (& new_bpart );
200
202
while (1 ) {
201
203
while (bpart && world < bpart -> min_world ) {
202
204
insert = & bpart -> next ;
203
205
max_world = bpart -> min_world - 1 ;
204
206
parent = (jl_value_t * )bpart ;
205
207
bpart = jl_atomic_load_relaxed (& bpart -> next );
206
208
}
207
- if (bpart && world <= jl_atomic_load_relaxed (& bpart -> max_world ))
209
+ if (bpart && world <= jl_atomic_load_relaxed (& bpart -> max_world )) {
210
+ JL_GC_POP ();
208
211
return bpart ;
212
+ }
209
213
if (!new_bpart )
210
214
new_bpart = new_binding_partition ();
211
215
jl_atomic_store_relaxed (& new_bpart -> next , bpart );
212
216
if (bpart )
213
217
jl_gc_wb (new_bpart , bpart ); // Not fresh the second time around the loop
214
218
new_bpart -> min_world = bpart ? jl_atomic_load_relaxed (& bpart -> max_world ) + 1 : 0 ;
215
219
jl_atomic_store_relaxed (& new_bpart -> max_world , max_world );
216
- JL_GC_PROMISE_ROOTED (new_bpart ); // TODO: Analyzer doesn't understand MAYBE_UNROOTED properly
217
220
jl_check_new_binding_implicit (new_bpart , b , st , world );
218
221
if (bpart && (bpart -> kind & PARTITION_FLAG_EXPORTED ))
219
222
new_bpart -> kind |= PARTITION_FLAG_EXPORTED ;
220
223
if (jl_atomic_cmpswap (insert , & bpart , new_bpart )) {
221
224
jl_gc_wb (parent , new_bpart );
225
+ JL_GC_POP ();
222
226
return new_bpart ;
223
227
}
224
228
}
@@ -1435,7 +1439,7 @@ JL_DLLEXPORT jl_binding_partition_t *jl_replace_binding_locked2(jl_binding_t *b,
1435
1439
new_bpart -> min_world = new_world ;
1436
1440
if ((kind & PARTITION_MASK_KIND ) == PARTITION_KIND_IMPLICIT_RECOMPUTE ) {
1437
1441
assert (!restriction_val );
1438
- jl_check_new_binding_implicit (new_bpart /* callee rooted */ , b , NULL , new_world );
1442
+ jl_check_new_binding_implicit (new_bpart , b , NULL , new_world );
1439
1443
new_bpart -> kind |= kind & PARTITION_MASK_FLAG ;
1440
1444
if (new_bpart -> kind == old_bpart -> kind && new_bpart -> restriction == old_bpart -> restriction ) {
1441
1445
JL_GC_POP ();
0 commit comments