Skip to content

Commit f91572e

Browse files
authored
bpart: Rename partition flags, turn binding flags atomic (JuliaLang#57614)
This renames the partition flags to start with PARTITION_ and turns the Binding flags into a bitfield that can be accessed atomically in preparation for adding further flags.
1 parent bffb691 commit f91572e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Compiler.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ using Core: ABIOverride, Builtin, CodeInstance, IntrinsicFunction, MethodInstanc
4949

5050
using Base
5151
using Base: @_foldable_meta, @_gc_preserve_begin, @_gc_preserve_end, @nospecializeinfer,
52-
BINDING_KIND_GLOBAL, BINDING_KIND_UNDEF_CONST, BINDING_KIND_BACKDATED_CONST, BINDING_KIND_DECLARED,
53-
BINDING_FLAG_DEPWARN,
52+
PARTITION_KIND_GLOBAL, PARTITION_KIND_UNDEF_CONST, PARTITION_KIND_BACKDATED_CONST, PARTITION_KIND_DECLARED,
53+
PARTITION_FLAG_DEPWARN,
5454
Base, BitVector, Bottom, Callable, DataTypeFieldDesc,
5555
EffectsOverride, Filter, Generator, IteratorSize, JLOptions, NUM_EFFECTS_OVERRIDES,
5656
OneTo, Ordering, RefValue, SizeUnknown, _NAMEDTUPLE_NAME,

src/abstractinterpretation.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,7 @@ end
24412441
(valid_worlds, rt) = scan_leaf_partitions(interp, gr, sv.world) do interp, _, partition
24422442
local rt
24432443
kind = binding_kind(partition)
2444-
if is_some_guard(kind) || kind == BINDING_KIND_DECLARED
2444+
if is_some_guard(kind) || kind == PARTITION_KIND_DECLARED
24452445
# We do not currently assume an invalidation for guard -> defined transitions
24462446
# rt = Const(nothing)
24472447
rt = Type
@@ -2572,7 +2572,7 @@ function abstract_eval_replaceglobal!(interp::AbstractInterpreter, sv::AbsIntSta
25722572
(valid_worlds, (rte, T)) = scan_leaf_partitions(interp, gr, sv.world) do interp, _, partition
25732573
partition_T = nothing
25742574
partition_rte = abstract_eval_partition_load(interp, partition)
2575-
if binding_kind(partition) == BINDING_KIND_GLOBAL
2575+
if binding_kind(partition) == PARTITION_KIND_GLOBAL
25762576
partition_T = partition_restriction(partition)
25772577
end
25782578
partition_exct = Union{partition_rte.exct, global_assignment_binding_rt_exct(interp, partition, v)[2]}
@@ -3552,9 +3552,9 @@ abstract_eval_partition_load(interp::Union{AbstractInterpreter, Nothing}, ::Core
35523552
abstract_eval_partition_load(interp, partition)
35533553
function abstract_eval_partition_load(interp::Union{AbstractInterpreter, Nothing}, partition::Core.BindingPartition)
35543554
kind = binding_kind(partition)
3555-
isdepwarn = (partition.kind & BINDING_FLAG_DEPWARN) != 0
3555+
isdepwarn = (partition.kind & PARTITION_FLAG_DEPWARN) != 0
35563556
local_getglobal_effects = Effects(generic_getglobal_effects, effect_free=isdepwarn ? ALWAYS_FALSE : ALWAYS_TRUE)
3557-
if is_some_guard(kind) || kind == BINDING_KIND_UNDEF_CONST
3557+
if is_some_guard(kind) || kind == PARTITION_KIND_UNDEF_CONST
35583558
if interp !== nothing && InferenceParams(interp).assume_bindings_static
35593559
return RTEffects(Union{}, UndefVarError, EFFECTS_THROWS)
35603560
else
@@ -3565,7 +3565,7 @@ function abstract_eval_partition_load(interp::Union{AbstractInterpreter, Nothing
35653565
end
35663566

35673567
if is_defined_const_binding(kind)
3568-
if kind == BINDING_KIND_BACKDATED_CONST
3568+
if kind == PARTITION_KIND_BACKDATED_CONST
35693569
# Infer this as guard. We do not want a later const definition to retroactively improve
35703570
# inference results in an earlier world.
35713571
return RTEffects(Any, UndefVarError, local_getglobal_effects)
@@ -3576,7 +3576,7 @@ function abstract_eval_partition_load(interp::Union{AbstractInterpreter, Nothing
35763576
effect_free=isdepwarn ? ALWAYS_FALSE : ALWAYS_TRUE))
35773577
end
35783578

3579-
if kind == BINDING_KIND_DECLARED
3579+
if kind == PARTITION_KIND_DECLARED
35803580
# Could be replaced by a backdated const which has an effect, so we can't assume it won't.
35813581
# Besides, we would prefer not to merge the world range for this into the world range for
35823582
# _GLOBAL, because that would pessimize codegen.
@@ -3643,7 +3643,7 @@ function abstract_eval_globalref(interp, g::GlobalRef, saw_latestworld::Bool, sv
36433643
# binding we end up reaching such that codegen can emit a simpler pointer load.
36443644
Pair{RTEffects, Union{Nothing, Core.Binding}}(
36453645
abstract_eval_partition_load(interp, partition),
3646-
binding_kind(partition) in (BINDING_KIND_GLOBAL, BINDING_KIND_DECLARED) ? binding : nothing)
3646+
binding_kind(partition) in (PARTITION_KIND_GLOBAL, PARTITION_KIND_DECLARED) ? binding : nothing)
36473647
end
36483648
update_valid_age!(sv, valid_worlds)
36493649
if ret.rt !== Union{} && ret.exct === UndefVarError && binding_if_global !== nothing && InferenceParams(interp).assume_bindings_static
@@ -3672,7 +3672,7 @@ function global_assignment_binding_rt_exct(interp::AbstractInterpreter, partitio
36723672
elseif is_some_const_binding(kind) || is_some_imported(kind)
36733673
return Pair{Any,Any}(Bottom, ErrorException)
36743674
end
3675-
ty = kind == BINDING_KIND_DECLARED ? Any : partition_restriction(partition)
3675+
ty = kind == PARTITION_KIND_DECLARED ? Any : partition_restriction(partition)
36763676
wnewty = widenconst(newty)
36773677
if !hasintersect(wnewty, ty)
36783678
return Pair{Any,Any}(Bottom, TypeError)

0 commit comments

Comments
 (0)