Skip to content

Backports for 1.12.0-beta3 #58270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 50 commits into
base: release-1.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a2afe89
Narrow `@inbounds` annotations in `accumulate.jl` to only indexing ca…
adienes Apr 24, 2025
e54f907
"improve" allocations macro with more functions (#58057)
vtjnash Apr 24, 2025
56b254e
improve type stability of `stat` (#58212)
aviatesk Apr 25, 2025
bef1824
optimize Type method table queries and insertions (#58216)
vtjnash Apr 25, 2025
fe64e54
Specialize `one` for the `SizedArray` test helper (#58209)
jishnub Apr 26, 2025
3b602f6
Subtype: enable more Tuple related fast path. (#58196)
N5N3 Apr 27, 2025
cf8bb28
[REPLCompletions] use better version of listing module imports for co…
vtjnash Apr 28, 2025
a962d90
Update MozillaCACerts_jll to 2025-02-25 (#58248)
eschnett Apr 28, 2025
8d59049
Update deps to OpenSSL 3.5.0 (#58247)
eschnett Apr 28, 2025
4e7ddaa
add PARTITION_KIND_BACKDATED_CONST to UndefVarError_hint (#58260)
vtjnash Apr 29, 2025
191fc25
improve isdefined precision for 0 field types (#58220)
oscardssmith May 3, 2025
9e323a5
Add manual chapter on world age and binding partition (#58253)
Keno Apr 30, 2025
e69092e
docs: some minor follow-up to JuliaLang/julia#58253 (#58314)
aviatesk May 5, 2025
8a40ccf
Add 1.12 NEWS entry on binding partition (#58297)
Keno May 5, 2025
133d524
clarify that time_ns is monotonic (#57129)
stevengj Apr 29, 2025
4a9dae5
doc: cross-reference `bind` in `Channel` method doc string (#58113)
nsajko Apr 29, 2025
62a3fef
Note annotated string API is experimental in Julia 1.11 in HISTORY.md…
nhz2 Apr 29, 2025
31b0930
Tracy: annotate timings in `JIT_Total` zone with function names
mlechu Apr 24, 2025
bcc885c
OncePerX: Improve initializer type for DataType constructors (#58265)
topolarity Apr 30, 2025
6bb1a24
Strengthen language around `@assume_effects` :consistent (#58254)
Keno Apr 30, 2025
e01179c
Print fallback REPL prompt before user input (#58210)
xal-0 Apr 30, 2025
331cb3f
fix: give access to displaysize when displaying at REPL (#58121)
rfourquet May 2, 2025
18dd371
Fix lowering failure with type parameter in opaque closure (#58307)
mlechu May 3, 2025
79c45b8
Make build_id.lo more random (#58258)
gbaraldi May 3, 2025
72b8474
add backdate_admonition to depwarn=error (#58266)
vtjnash May 3, 2025
dd50abb
test/trimming: Use `SHLIB_EXT` in Makefile
staticfloat Mar 16, 2025
6a16596
staticdata: fix many mistakes in staticdata stripping (#58166)
vtjnash Apr 19, 2025
fdb6a0d
bpart: Fix a hang in a particular corner case (#58271)
Keno Apr 30, 2025
804c2ce
Remove usages of weak symbols (#57523)
topolarity Feb 27, 2025
9e913d7
Prevent type infer hang of "simple" recursive functions (#58273)
vtjnash May 2, 2025
925d41c
bump Pkg to latest v1.12
KristofferC May 5, 2025
eb09ae1
staticdata: Refactor sysimage loading (#57542)
gbaraldi May 5, 2025
7da3d4b
Add hook to initialize Julia on-the-fly during thread adoption (#56334)
gbaraldi Feb 26, 2025
66ade55
Make trimmed binaries initialize on first call (#58141)
gbaraldi Apr 17, 2025
dd17a4f
Refactor julia initialization by finding and loading the sysimage ear…
topolarity May 2, 2025
0e2d835
trimming: Remove `init.c` from test (#58197)
topolarity May 2, 2025
ccece94
add the ability to specify the external name of a ccallable
JeffBezanson Mar 13, 2025
6bab302
remove unused argument from jl_generate_ccallable
JeffBezanson Mar 19, 2025
66b7bd0
Don't use sigatomic before current task is available
gbaraldi May 5, 2025
3efd841
trim: Add `Core.finalizer` support
topolarity Apr 3, 2025
08705ab
some fixes
JeffBezanson Apr 4, 2025
1697857
typeinfer: add separate compile workqueue for native / call_latest code
topolarity Apr 4, 2025
17aa423
Make `empty!(::BitSet)` work during bootstrap
topolarity Apr 9, 2025
96e9942
Collect invoke only for `ftyp === typeof(finalizer)`
topolarity Apr 12, 2025
f3cbeef
typeinfer: Work around inference bug
topolarity Apr 16, 2025
dd392bf
Adjust `--trim` tests for new functionality
topolarity Apr 16, 2025
fc7c7b7
trimming: follow-ups to finalizer support
topolarity May 2, 2025
6e76091
improve robustness of `Vararg` checks in newly added `abstract_eval_x…
aviatesk May 6, 2025
d433021
use `src.nargs` for `validate_code!` (#58327)
aviatesk May 6, 2025
4348e89
Apply some of the trimming patches to 1.12 (#58321)
KristofferC May 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 123 additions & 70 deletions Compiler/src/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2421,11 +2421,15 @@ function abstract_eval_getglobal(interp::AbstractInterpreter, sv::AbsIntState, s
end

function abstract_eval_getglobal(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, argtypes::Vector{Any})
if length(argtypes) == 3
return abstract_eval_getglobal(interp, sv, saw_latestworld, argtypes[2], argtypes[3])
elseif length(argtypes) == 4
return abstract_eval_getglobal(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4])
elseif !isvarargtype(argtypes[end]) || length(argtypes) > 5
if !isvarargtype(argtypes[end])
if length(argtypes) == 3
return abstract_eval_getglobal(interp, sv, saw_latestworld, argtypes[2], argtypes[3])
elseif length(argtypes) == 4
return abstract_eval_getglobal(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4])
else
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
end
elseif length(argtypes) > 5
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
else
return CallMeta(Any, generic_getglobal_exct, generic_getglobal_effects, NoCallInfo())
Expand Down Expand Up @@ -2466,12 +2470,17 @@ end
end

function abstract_eval_get_binding_type(interp::AbstractInterpreter, sv::AbsIntState, argtypes::Vector{Any})
if length(argtypes) == 3
return abstract_eval_get_binding_type(interp, sv, argtypes[2], argtypes[3])
elseif !isvarargtype(argtypes[end]) || length(argtypes) > 4
if !isvarargtype(argtypes[end])
if length(argtypes) == 3
return abstract_eval_get_binding_type(interp, sv, argtypes[2], argtypes[3])
else
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
end
elseif length(argtypes) > 4
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
else
return CallMeta(Type, Union{TypeError, ArgumentError}, EFFECTS_THROWS, NoCallInfo())
end
return CallMeta(Type, Union{TypeError, ArgumentError}, EFFECTS_THROWS, NoCallInfo())
end

const setglobal!_effects = Effects(EFFECTS_TOTAL; effect_free=ALWAYS_FALSE, nothrow=false, inaccessiblememonly=ALWAYS_FALSE)
Expand Down Expand Up @@ -2504,11 +2513,15 @@ end
const generic_setglobal!_exct = Union{ArgumentError, TypeError, ErrorException, ConcurrencyViolationError}

function abstract_eval_setglobal!(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, argtypes::Vector{Any})
if length(argtypes) == 4
return abstract_eval_setglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4])
elseif length(argtypes) == 5
return abstract_eval_setglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4], argtypes[5])
elseif !isvarargtype(argtypes[end]) || length(argtypes) > 6
if !isvarargtype(argtypes[end])
if length(argtypes) == 4
return abstract_eval_setglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4])
elseif length(argtypes) == 5
return abstract_eval_setglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4], argtypes[5])
else
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
end
elseif length(argtypes) > 6
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
else
return CallMeta(Any, generic_setglobal!_exct, setglobal!_effects, NoCallInfo())
Expand All @@ -2532,75 +2545,87 @@ function abstract_eval_swapglobal!(interp::AbstractInterpreter, sv::AbsIntState,
end

function abstract_eval_swapglobal!(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, argtypes::Vector{Any})
if length(argtypes) == 4
return abstract_eval_swapglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4])
elseif length(argtypes) == 5
return abstract_eval_swapglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4], argtypes[5])
elseif !isvarargtype(argtypes[end]) || length(argtypes) > 6
if !isvarargtype(argtypes[end])
if length(argtypes) == 4
return abstract_eval_swapglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4])
elseif length(argtypes) == 5
return abstract_eval_swapglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4], argtypes[5])
else
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
end
elseif length(argtypes) > 6
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
else
return CallMeta(Any, Union{generic_getglobal_exct,generic_setglobal!_exct}, setglobal!_effects, NoCallInfo())
end
end

function abstract_eval_setglobalonce!(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, argtypes::Vector{Any})
if length(argtypes) in (4, 5, 6)
cm = abstract_eval_setglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4])
if length(argtypes) >= 5
goe = global_order_exct(argtypes[5], #=loading=#true, #=storing=#true)
cm = merge_exct(cm, goe)
end
if length(argtypes) == 6
goe = global_order_exct(argtypes[6], #=loading=#true, #=storing=#false)
cm = merge_exct(cm, goe)
end
return CallMeta(Bool, cm.exct, cm.effects, cm.info)
elseif !isvarargtype(argtypes[end]) || length(argtypes) > 6
if !isvarargtype(argtypes[end])
if length(argtypes) in (4, 5, 6)
cm = abstract_eval_setglobal!(interp, sv, saw_latestworld, argtypes[2], argtypes[3], argtypes[4])
if length(argtypes) >= 5
goe = global_order_exct(argtypes[5], #=loading=#true, #=storing=#true)
cm = merge_exct(cm, goe)
end
if length(argtypes) == 6
goe = global_order_exct(argtypes[6], #=loading=#true, #=storing=#false)
cm = merge_exct(cm, goe)
end
return CallMeta(Bool, cm.exct, cm.effects, cm.info)
else
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
end
elseif length(argtypes) > 7
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
else
return CallMeta(Bool, generic_setglobal!_exct, setglobal!_effects, NoCallInfo())
end
end

function abstract_eval_replaceglobal!(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, argtypes::Vector{Any})
if length(argtypes) in (5, 6, 7)
(M, s, x, v) = argtypes[2], argtypes[3], argtypes[4], argtypes[5]
T = nothing
if isa(M, Const) && isa(s, Const)
M, s = M.val, s.val
M isa Module || return CallMeta(Union{}, TypeError, EFFECTS_THROWS, NoCallInfo())
s isa Symbol || return CallMeta(Union{}, TypeError, EFFECTS_THROWS, NoCallInfo())
gr = GlobalRef(M, s)
v′ = RefValue{Any}(v)
(valid_worlds, (rte, T)) = scan_leaf_partitions(interp, gr, sv.world) do interp::AbstractInterpreter, binding::Core.Binding, partition::Core.BindingPartition
partition_T = nothing
partition_rte = abstract_eval_partition_load(interp, binding, partition)
if binding_kind(partition) == PARTITION_KIND_GLOBAL
partition_T = partition_restriction(partition)
if !isvarargtype(argtypes[end])
if length(argtypes) in (5, 6, 7)
(M, s, x, v) = argtypes[2], argtypes[3], argtypes[4], argtypes[5]
T = nothing
if isa(M, Const) && isa(s, Const)
M, s = M.val, s.val
M isa Module || return CallMeta(Union{}, TypeError, EFFECTS_THROWS, NoCallInfo())
s isa Symbol || return CallMeta(Union{}, TypeError, EFFECTS_THROWS, NoCallInfo())
gr = GlobalRef(M, s)
v′ = RefValue{Any}(v)
(valid_worlds, (rte, T)) = scan_leaf_partitions(interp, gr, sv.world) do interp::AbstractInterpreter, binding::Core.Binding, partition::Core.BindingPartition
partition_T = nothing
partition_rte = abstract_eval_partition_load(interp, binding, partition)
if binding_kind(partition) == PARTITION_KIND_GLOBAL
partition_T = partition_restriction(partition)
end
partition_exct = Union{partition_rte.exct, global_assignment_binding_rt_exct(interp, partition, v′[])[2]}
partition_rte = RTEffects(partition_rte.rt, partition_exct, partition_rte.effects)
Pair{RTEffects, Any}(partition_rte, partition_T)
end
partition_exct = Union{partition_rte.exct, global_assignment_binding_rt_exct(interp, partition, v′[])[2]}
partition_rte = RTEffects(partition_rte.rt, partition_exct, partition_rte.effects)
Pair{RTEffects, Any}(partition_rte, partition_T)
update_valid_age!(sv, valid_worlds)
effects = merge_effects(rte.effects, Effects(setglobal!_effects, nothrow=rte.exct===Bottom))
sg = CallMeta(Any, rte.exct, effects, GlobalAccessInfo(convert(Core.Binding, gr)))
else
sg = abstract_eval_setglobal!(interp, sv, saw_latestworld, M, s, v)
end
if length(argtypes) >= 6
goe = global_order_exct(argtypes[6], #=loading=#true, #=storing=#true)
sg = merge_exct(sg, goe)
end
update_valid_age!(sv, valid_worlds)
effects = merge_effects(rte.effects, Effects(setglobal!_effects, nothrow=rte.exct===Bottom))
sg = CallMeta(Any, rte.exct, effects, GlobalAccessInfo(convert(Core.Binding, gr)))
if length(argtypes) == 7
goe = global_order_exct(argtypes[7], #=loading=#true, #=storing=#false)
sg = merge_exct(sg, goe)
end
rt = T === nothing ?
ccall(:jl_apply_cmpswap_type, Any, (Any,), S) where S :
ccall(:jl_apply_cmpswap_type, Any, (Any,), T)
return CallMeta(rt, sg.exct, sg.effects, sg.info)
else
sg = abstract_eval_setglobal!(interp, sv, saw_latestworld, M, s, v)
end
if length(argtypes) >= 6
goe = global_order_exct(argtypes[6], #=loading=#true, #=storing=#true)
sg = merge_exct(sg, goe)
end
if length(argtypes) == 7
goe = global_order_exct(argtypes[7], #=loading=#true, #=storing=#false)
sg = merge_exct(sg, goe)
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
end
rt = T === nothing ?
ccall(:jl_apply_cmpswap_type, Any, (Any,), S) where S :
ccall(:jl_apply_cmpswap_type, Any, (Any,), T)
return CallMeta(rt, sg.exct, sg.effects, sg.info)
elseif !isvarargtype(argtypes[end]) || length(argtypes) > 8
elseif length(argtypes) > 8
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
else
return CallMeta(Any, Union{generic_getglobal_exct,generic_setglobal!_exct}, setglobal!_effects, NoCallInfo())
Expand Down Expand Up @@ -2655,11 +2680,8 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
return Future(abstract_eval_isdefinedglobal(interp, argtypes[2], argtypes[3], Const(true),
length(argtypes) == 4 ? argtypes[4] : Const(:unordered),
si.saw_latestworld, sv))
elseif f === Core.isdefinedglobal && 3 <= length(argtypes) <= 5
return Future(abstract_eval_isdefinedglobal(interp, argtypes[2], argtypes[3],
length(argtypes) >= 4 ? argtypes[4] : Const(true),
length(argtypes) >= 5 ? argtypes[5] : Const(:unordered),
si.saw_latestworld, sv))
elseif f === Core.isdefinedglobal
return Future(abstract_eval_isdefinedglobal(interp, sv, si.saw_latestworld, argtypes))
elseif f === Core.get_binding_type
return Future(abstract_eval_get_binding_type(interp, sv, argtypes))
end
Expand Down Expand Up @@ -3299,6 +3321,23 @@ function abstract_eval_isdefinedglobal(interp::AbstractInterpreter, @nospecializ
return CallMeta(Bool, Union{exct, TypeError, UndefVarError}, generic_isdefinedglobal_effects, NoCallInfo())
end

function abstract_eval_isdefinedglobal(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, argtypes::Vector{Any})
if !isvarargtype(argtypes[end])
if 3 <= length(argtypes) <= 5
return abstract_eval_isdefinedglobal(interp, argtypes[2], argtypes[3],
length(argtypes) >= 4 ? argtypes[4] : Const(true),
length(argtypes) >= 5 ? argtypes[5] : Const(:unordered),
saw_latestworld, sv)
else
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
end
elseif length(argtypes) > 6
return CallMeta(Union{}, ArgumentError, EFFECTS_THROWS, NoCallInfo())
else
return CallMeta(Bool, Union{ConcurrencyViolationError, TypeError, UndefVarError}, generic_isdefinedglobal_effects, NoCallInfo())
end
end

function abstract_eval_throw_undef_if_not(interp::AbstractInterpreter, e::Expr, sstate::StatementState, sv::AbsIntState)
condt = abstract_eval_value(interp, e.args[2], sstate, sv)
condval = maybe_extract_const_bool(condt)
Expand Down Expand Up @@ -3452,6 +3491,20 @@ function merge_override_effects!(interp::AbstractInterpreter, effects::Effects,
# It is possible for arguments (GlobalRef/:static_parameter) to throw,
# but these will be recomputed during SSA construction later.
override = decode_statement_effects_override(sv)
if override.consistent
m = sv.linfo.def
if isa(m, Method)
# N.B.: We'd like deleted_world here, but we can't add an appropriate edge at this point.
# However, in order to reach here in the first place, ordinary method lookup would have
# had to add an edge and appropriate invalidation trigger.
valid_worlds = WorldRange(m.primary_world, typemax(Int))
if sv.world.this in valid_worlds
update_valid_age!(sv, valid_worlds)
else
override = EffectsOverride(override, consistent=false)
end
end
end
effects = override_effects(effects, override)
set_curr_ssaflag!(sv, flags_for_effects(effects), IR_FLAGS_EFFECTS)
merge_effects!(interp, sv, effects)
Expand Down
4 changes: 4 additions & 0 deletions Compiler/src/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ end
return Const(true)
end
end
# datatype_fieldcount is what `fieldcount` uses internally
# and returns nothing (!==0) for non-definite field counts.
elseif datatype_fieldcount(a1) === 0
return Const(false)
end
elseif isa(a1, Union)
# Results can only be `Const` or `Bool`
Expand Down
Loading