@@ -3435,26 +3435,33 @@ static jl_value_t *jl_ensure_rooted(jl_codectx_t &ctx, jl_value_t *val)
3435
3435
3436
3436
// --- generating function calls ---
3437
3437
3438
+ static jl_cgval_t emit_globalref_runtime (jl_codectx_t &ctx, jl_binding_t *bnd, jl_module_t *mod, jl_sym_t *name)
3439
+ {
3440
+ Value *bp = julia_binding_gv (ctx, bnd);
3441
+ Value *v = ctx.builder .CreateCall (prepare_call (jlgetbindingvalue_func), { bp });
3442
+ undef_var_error_ifnot (ctx, ctx.builder .CreateIsNotNull (v), name, (jl_value_t *)mod);
3443
+ return mark_julia_type (ctx, v, true , jl_any_type);
3444
+ }
3445
+
3438
3446
static jl_cgval_t emit_globalref (jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *name, AtomicOrdering order)
3439
3447
{
3440
3448
jl_binding_t *bnd = jl_get_module_binding (mod, name, 1 );
3441
- jl_binding_partition_t *bpart = jl_get_binding_partition (bnd, ctx.max_world );
3449
+ assert (bnd);
3450
+ jl_binding_partition_t *bpart = jl_get_binding_partition_all (bnd, ctx.min_world , ctx.max_world );
3451
+ if (!bpart) {
3452
+ return emit_globalref_runtime (ctx, bnd, mod, name);
3453
+ }
3442
3454
jl_ptr_kind_union_t pku = jl_atomic_load_relaxed (&bpart->restriction );
3443
3455
if (jl_bkind_is_some_guard (decode_restriction_kind (pku))) {
3444
3456
// try to look this up now.
3445
3457
// TODO: This is bad and we'd like to delete it.
3446
3458
jl_get_binding (mod, name);
3447
3459
}
3448
- assert (bnd);
3449
- Value *bp = NULL ;
3450
3460
// bpart was updated in place - this will change with full partition
3451
3461
pku = jl_atomic_load_acquire (&bpart->restriction );
3452
3462
if (jl_bkind_is_some_guard (decode_restriction_kind (pku))) {
3453
3463
// Redo the lookup at runtime
3454
- bp = julia_binding_gv (ctx, bnd);
3455
- Value *v = ctx.builder .CreateCall (prepare_call (jlgetbindingvalue_func), { bp });
3456
- undef_var_error_ifnot (ctx, ctx.builder .CreateIsNotNull (v), name, (jl_value_t *)mod);
3457
- return mark_julia_type (ctx, v, true , jl_any_type);
3464
+ return emit_globalref_runtime (ctx, bnd, mod, name);
3458
3465
} else {
3459
3466
while (true ) {
3460
3467
if (!bpart)
@@ -3465,7 +3472,9 @@ static jl_cgval_t emit_globalref(jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *
3465
3472
cg_bdw (ctx, name, bnd);
3466
3473
}
3467
3474
bnd = (jl_binding_t *)decode_restriction_value (pku);
3468
- bpart = jl_get_binding_partition (bnd, ctx.max_world );
3475
+ bpart = jl_get_binding_partition_all (bnd, ctx.min_world , ctx.max_world );
3476
+ if (!bpart)
3477
+ break ;
3469
3478
pku = jl_atomic_load_acquire (&bpart->restriction );
3470
3479
}
3471
3480
if (bpart && jl_bkind_is_some_constant (decode_restriction_kind (pku))) {
@@ -3477,7 +3486,10 @@ static jl_cgval_t emit_globalref(jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *
3477
3486
return mark_julia_const (ctx, constval);
3478
3487
}
3479
3488
}
3480
- bp = julia_binding_gv (ctx, bnd);
3489
+ if (!bpart) {
3490
+ return emit_globalref_runtime (ctx, bnd, mod, name);
3491
+ }
3492
+ Value *bp = julia_binding_gv (ctx, bnd);
3481
3493
if (bnd->deprecated ) {
3482
3494
cg_bdw (ctx, name, bnd);
3483
3495
}
@@ -3496,7 +3508,7 @@ static jl_cgval_t emit_globalop(jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *s
3496
3508
{
3497
3509
jl_binding_t *bnd = NULL ;
3498
3510
Value *bp = global_binding_pointer (ctx, mod, sym, &bnd, true , alloc);
3499
- jl_binding_partition_t *bpart = jl_get_binding_partition (bnd, ctx.max_world );
3511
+ jl_binding_partition_t *bpart = jl_get_binding_partition_all (bnd, ctx. min_world , ctx.max_world );
3500
3512
if (bp == NULL )
3501
3513
return jl_cgval_t ();
3502
3514
if (bpart) {
@@ -5854,7 +5866,7 @@ static Value *global_binding_pointer(jl_codectx_t &ctx, jl_module_t *m, jl_sym_t
5854
5866
jl_binding_t **pbnd, bool assign, bool alloc)
5855
5867
{
5856
5868
jl_binding_t *b = jl_get_module_binding (m, s, 1 );
5857
- jl_binding_partition_t *bpart = jl_get_binding_partition (b , ctx.max_world );
5869
+ jl_binding_partition_t *bpart = jl_get_binding_partition_all (b, ctx. min_world , ctx.max_world );
5858
5870
jl_ptr_kind_union_t pku = jl_atomic_load_relaxed (&bpart->restriction );
5859
5871
if (assign) {
5860
5872
if (jl_bkind_is_some_guard (decode_restriction_kind (pku)))
@@ -5865,11 +5877,11 @@ static Value *global_binding_pointer(jl_codectx_t &ctx, jl_module_t *m, jl_sym_t
5865
5877
if (jl_bkind_is_some_guard (decode_restriction_kind (pku))) {
5866
5878
// try to look this up now
5867
5879
b = jl_get_binding (m, s);
5868
- bpart = jl_get_binding_partition (b , ctx.max_world );
5880
+ bpart = jl_get_binding_partition_all (b, ctx. min_world , ctx.max_world );
5869
5881
}
5870
- pku = jl_walk_binding_inplace (&b, &bpart, ctx.max_world );
5882
+ pku = jl_walk_binding_inplace_all (&b, &bpart, ctx. min_world , ctx.max_world );
5871
5883
}
5872
- if (b == NULL ) {
5884
+ if (!b || !bpart ) {
5873
5885
// var not found. switch to delayed lookup.
5874
5886
Constant *initnul = Constant::getNullValue (ctx.types ().T_pjlvalue );
5875
5887
GlobalVariable *bindinggv = new GlobalVariable (*ctx.f ->getParent (), ctx.types ().T_pjlvalue ,
@@ -6021,7 +6033,7 @@ static jl_cgval_t emit_isdefined(jl_codectx_t &ctx, jl_value_t *sym, int allow_i
6021
6033
name = (jl_sym_t *)sym;
6022
6034
}
6023
6035
jl_binding_t *bnd = allow_import ? jl_get_binding (modu, name) : jl_get_module_binding (modu, name, 0 );
6024
- jl_binding_partition_t *bpart = jl_get_binding_partition (bnd, ctx.min_world );
6036
+ jl_binding_partition_t *bpart = jl_get_binding_partition_all (bnd, ctx.min_world , ctx. max_world );
6025
6037
jl_ptr_kind_union_t pku = bpart ? jl_atomic_load_relaxed (&bpart->restriction ) : encode_restriction (NULL , BINDING_KIND_GUARD);
6026
6038
if (decode_restriction_kind (pku) == BINDING_KIND_GLOBAL || jl_bkind_is_some_constant (decode_restriction_kind (pku))) {
6027
6039
if (jl_get_binding_value_if_const (bnd))
0 commit comments