Skip to content

Backports for 1.12.0-rc1 #58655

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

Merged
merged 83 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
9d665ff
gf.c: Fix backedge de-duplication bug (#58106)
topolarity Apr 15, 2025
42dabfd
typeinfer: De-duplicate backedges as they are stored
topolarity Apr 14, 2025
c0aaabe
staticdata: do not serialize backedges for `MethodInstance` / `Method…
topolarity Apr 14, 2025
b2aa9a2
gf.c: make edge de-duplication a caller responsibility
topolarity Apr 14, 2025
4206e21
Update back-edge de-duplication test
topolarity May 8, 2025
63df577
reduce places where Builtins are listed (#58205)
vtjnash Apr 24, 2025
bc9450e
staticdata: prune backedges table during serialization (#58156)
vtjnash Apr 20, 2025
be99f9e
make just one MethodTable (#58131)
vtjnash May 28, 2025
7db505b
MethodTable/Cache PR updates (#58565)
vtjnash May 29, 2025
54c51d9
fix breakage with `jl_get_global` (#58540)
vtjnash May 29, 2025
2eb17ec
Detect Apple M4 and some related changes (#58301)
fingolfin Jun 5, 2025
e66fbe4
Update install link in warning (#58638)
IanButterworth Jun 5, 2025
bc65d98
ircode: handle content outside of a module (#58639)
vtjnash Jun 5, 2025
31bc1b7
Use type wrapper directly rather than typename in `FieldError` (#58507)
MasonProtter Jun 6, 2025
235a7de
module: Tweak backdate-warning-turned error (#58651)
Keno Jun 6, 2025
dede289
bump Pkg to latest 1.12
Jun 11, 2025
eced41d
Try workaround for https://github.com/JuliaLang/www.julialang.org/iss…
staticfloat Jun 8, 2025
1aa7a50
Adjust applescript workaround
staticfloat Jun 8, 2025
d87f8f9
better handling of missing backedges (#58636)
vtjnash Jun 9, 2025
9c702e9
improve inferred effects for `reshape` for `Array` (#58672)
nsajko Jun 9, 2025
6a96201
Unicode: Force-inline isgraphemebreak! (#58674)
Keno Jun 10, 2025
4479c55
Test: Fix failfast for for loops (#58695)
IanButterworth Jun 11, 2025
bb4a890
restore fallback 3-arg `setprecision` method (#58586) (#58699)
JeffBezanson Jun 12, 2025
fb1e0fe
Set the branch for SparseArrays to release-1.12
fredrikekre Jun 13, 2025
533f2b8
🤖 [backports-release-1.12] Bump the LinearAlgebra stdlib from 7264a49…
DilumAluthgeBot Jun 14, 2025
c283757
🤖 [backports-release-1.12] Bump the SparseArrays stdlib from 72c7cac …
DilumAluthgeBot Jun 14, 2025
6136581
inference: improve `isdefined_tfunc` accuracy for `MustAlias` (#58743)
aviatesk Jun 17, 2025
870622a
Bump llvm to 18.1.7+5 to fix memcpyopt issue (#58610)
gbaraldi Jun 17, 2025
9d2db09
backport-1.12: move to the new versioning policy for Compiler stdlib …
aviatesk Jun 17, 2025
ed55ba4
bump Compiler.jl version to 0.1.1 (#58744)
aviatesk Jun 17, 2025
8d890cc
REPL: fix typo and potential `UndefVarError` (#58761)
aviatesk Jun 18, 2025
e1676c1
fix fallback code path in `take!(::IOBuffer)` method (#58762)
aviatesk Jun 18, 2025
8ec81e2
inform compiler about local variable definedness (#58778)
aviatesk Jun 20, 2025
fa82587
Update Pkg.version
IanButterworth Jun 21, 2025
92f258e
🤖 [backports-release-1.12] Bump the Pkg stdlib from 780260105 to b5f9…
DilumAluthgeBot Jun 22, 2025
9a857ac
Add compat note for OncePer types (#58716)
jakobnissen Jun 12, 2025
f650e9f
UnicodeData: Update to version 16 (#58710)
eschnett Jun 13, 2025
5d94660
Increment state conditionally in `CartesianIndices` iteration (#58742)
jishnub Jun 17, 2025
858eb0f
Work around LLVM JITLink stack overflow issue. (#58579)
gbaraldi Jun 17, 2025
5ae9342
Define textwidth for overlong chars (#58602)
jakobnissen Jun 18, 2025
aba3834
fix showing types after removing using Core (#58773)
vtjnash Jun 19, 2025
9a82567
Test: Hide REPL internals in backtraces (#58732)
IanButterworth Jun 20, 2025
0b32bbd
[libblastrampoline_jll] Upgrade to v5.13.1 (#58775)
amontoison Jun 21, 2025
da36d27
prevent unnecessary repeated squaring calculation (#58720)
nsajko Jun 22, 2025
ae38821
Add `cfunction` support for `--trim` (#58812)
topolarity Jun 26, 2025
de4204b
Add `trim_mode` parameter to JIT type-inference entrypoint (#58817)
topolarity Jun 27, 2025
4c68379
Make trimming tests work in an out-of-tree build. (#58340)
maleadt May 10, 2025
7ad2974
use `@main` for juliac executable entry point (#57588)
JeffBezanson May 22, 2025
6098097
codegen: ensure safepoint functions can read the pgcstack (#58804)
vtjnash Jun 25, 2025
08f6ee9
codegen: gc wb for atomic FCA stores (#58792)
vtjnash Jun 27, 2025
b608652
Revert "Scheduler: Use a "scheduler" task for thread sleep (#57544)"
kpamnany Jun 17, 2025
ddae588
libuv: Mark `(un)preserve_handle` as `@nospecialize` (#58844)
topolarity Jun 30, 2025
e3ef824
Fix broken `--trim` test due to `640c4e1` revert
topolarity Jul 1, 2025
e35e82b
fix `@invokelatest` performance regression (#58582)
vtjnash Jun 2, 2025
7e16e14
Add 0 predecessor to entry basic block and handle it in inlining (#58…
gbaraldi Jun 10, 2025
fc4066d
move trim patches to separate files, only load if trimming (#58826)
JeffBezanson Jun 30, 2025
2e45e64
juliac: Add rudimentary Windows support (#57481)
topolarity Jul 1, 2025
c37ee51
debuginfo: Memoize object symbol lookup (#58851)
topolarity Jul 1, 2025
1e24c2e
trimming: Add `_uv_hook_close` support (#58871)
topolarity Jul 2, 2025
06febe3
aotcompile: Fix early-exit if CI not found for `cfunction` (#58722)
topolarity Jul 2, 2025
4bb1f80
add back `to_power_type` to `deprecated.jl` since some packages call …
KristofferC Jul 4, 2025
e931e83
bump Pkg to latest 1.12
Jul 4, 2025
885f8e7
If the user explicitly asked for 1 thread don't add an interactive on…
gbaraldi Jun 4, 2025
b310ecf
fix module check for new Pkg module name
Jul 7, 2025
3830665
Remove bugged and typically slower `minimum`/`maximum` method (#58267)
mbauman May 7, 2025
3ca6ec5
fix null comparisons for non-standard address spaces (#58837)
simeonschaub Jul 1, 2025
8180b74
Re-add old function name for backward compatibility in init (#58860)
gbaraldi Jul 1, 2025
ba3d2d8
Add a `similar` method for `Type{<:CodeUnits}` (#57826)
ararslan Jul 2, 2025
ff0e323
Fix data race in jl_new_module__ (#58880)
xal-0 Jul 2, 2025
97f21e3
fix trailing indices stackoverflow in reinterpreted array (#58293)
adienes Jul 3, 2025
9517f81
OpenSSL: Update to 3.5.1 (#58876)
eschnett Jul 3, 2025
be73573
Add offset in `hvncat` dimension calculation to fix issue with 0-leng…
BioTurboNick Jul 3, 2025
f60e44b
Pkg: Allow configuring can_fancyprint(io::IO) using IOContext (#58887)
fonsp Jul 4, 2025
304847e
Define `in` for `CartesianIndex` ranges (#58616)
jishnub Jun 16, 2025
1ef9ca3
bpart: failed "edge" invalidation (#58336)
timholy May 10, 2025
a121e3b
Add binding invalidations to log (#58226)
timholy May 30, 2025
fa74542
bpart: Properly track methods with invalidated source after require_w…
Keno Jun 28, 2025
a28d9b4
add METHOD_SIG_LATEST_ONLY optimization to MethodInstance too (#58825)
vtjnash Jun 30, 2025
9a7388c
correctly encode and validate fully_covers as edges (#58861)
vtjnash Jul 7, 2025
c4e298c
Binding invalidation data race fixes (#58924)
KristofferC Jul 8, 2025
7c1ef00
Revert "Define `in` for `CartesianIndex` ranges (#58616)"
KristofferC Jul 8, 2025
aa56078
test: replcompletions: Replace timedwait by proper condvar (#58643)
Keno Jun 5, 2025
c1f27d2
🤖 [backports-release-1.12] Bump the Distributed stdlib from 51e5297 t…
DilumAluthgeBot Jul 8, 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
2 changes: 1 addition & 1 deletion Compiler/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2009-2024: Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors: https://github.com/JuliaLang/julia/contributors
Copyright (c) 2009-2025: Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors: https://github.com/JuliaLang/julia/contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Compiler"
uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
version = "0.0.3"
version = "0.1.1"

[compat]
julia = "1.10"
Expand Down
45 changes: 45 additions & 0 deletions Compiler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# The `Compiler` module

This directory maintains the implementation of the Julia compiler.

Through a bootstrapping process, it is bundled into the Julia runtime as `Base.Compiler`.

You can also use this `Compiler` module as the `Compiler` standard library by following the steps below.

## How to use

To utilize this `Compiler.jl` standard library, you need to declare it as a dependency in
your `Project.toml` as follows:
> Project.toml
```toml
[deps]
Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"

[compat]
Compiler = "0.1"
```

With the setup above, [the special placeholder version (v0.1)](https://github.com/JuliaLang/BaseCompiler.jl)
will be installed by default.[^1]

[^1]: Currently, only version v0.1 is registered in the [General](https://github.com/JuliaRegistries/General) registry.

If needed, you can switch to a custom implementation of the `Compiler` module by running
```julia-repl
pkg> dev /path/to/Compiler.jl # to use a local implementation
```
or
```julia-repl
pkg> add https://url/of/Compiler/branch # to use a remote implementation
```
This feature is particularly useful for developing or experimenting with alternative compiler implementations.

> [!note]
> The Compiler.jl standard library is available starting from Julia v1.10.
> However, switching to a custom compiler implementation is supported only from
> Julia v1.12 onwards.

> [!warning]
> When using a custom, non-`Base` version of `Compiler` implementation, it may be necessary
> to run `InteractiveUtils.@activate Compiler` to ensure proper functionality of certain
> reflection utilities.
2 changes: 1 addition & 1 deletion Compiler/src/Compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ else
using Core.Intrinsics, Core.IR

using Core: ABIOverride, Builtin, CodeInstance, IntrinsicFunction, MethodInstance, MethodMatch,
MethodTable, PartialOpaque, SimpleVector, TypeofVararg,
MethodTable, MethodCache, PartialOpaque, SimpleVector, TypeofVararg,
_apply_iterate, apply_type, compilerbarrier, donotdelete, memoryref_isassigned,
memoryrefget, memoryrefnew, memoryrefoffset, memoryrefset!, print, println, show, svec,
typename, unsafe_write, write
Expand Down
10 changes: 2 additions & 8 deletions Compiler/src/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,13 @@ function find_union_split_method_matches(interp::AbstractInterpreter, argtypes::
arg_n = split_argtypes[i]::Vector{Any}
sig_n = argtypes_to_type(arg_n)
sig_n === Bottom && continue
mt = ccall(:jl_method_table_for, Any, (Any,), sig_n)
mt === nothing && return FailedMethodMatch("Could not identify method table for call")
mt = mt::MethodTable
thismatches = findall(sig_n, method_table(interp); limit = max_methods)
if thismatches === nothing
return FailedMethodMatch("For one of the union split cases, too many methods matched")
end
valid_worlds = intersect(valid_worlds, thismatches.valid_worlds)
thisfullmatch = any(match::MethodMatch->match.fully_covers, thismatches)
mt = Core.GlobalMethods
thisinfo = MethodMatchInfo(thismatches, mt, sig_n, thisfullmatch)
push!(infos, thisinfo)
for idx = 1:length(thismatches)
Expand All @@ -385,18 +383,14 @@ function find_union_split_method_matches(interp::AbstractInterpreter, argtypes::
end

function find_simple_method_matches(interp::AbstractInterpreter, @nospecialize(atype), max_methods::Int)
mt = ccall(:jl_method_table_for, Any, (Any,), atype)
if mt === nothing
return FailedMethodMatch("Could not identify method table for call")
end
mt = mt::MethodTable
matches = findall(atype, method_table(interp); limit = max_methods)
if matches === nothing
# this means too many methods matched
# (assume this will always be true, so we don't compute / update valid age in this case)
return FailedMethodMatch("Too many methods matched")
end
fullmatch = any(match::MethodMatch->match.fully_covers, matches)
mt = Core.GlobalMethods
info = MethodMatchInfo(matches, mt, atype, fullmatch)
applicable = MethodMatchTarget[MethodMatchTarget(matches[idx], info.edges, idx) for idx = 1:length(matches)]
return MethodMatches(applicable, info, matches.valid_worlds)
Expand Down
4 changes: 2 additions & 2 deletions Compiler/src/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function activate_codegen!()
Core.eval(Compiler, quote
let typeinf_world_age = Base.tls_world_age()
@eval Core.OptimizedGenerics.CompilerPlugins.typeinf(::Nothing, mi::MethodInstance, source_mode::UInt8) =
Base.invoke_in_world($(Expr(:$, :typeinf_world_age)), typeinf_ext_toplevel, mi, Base.tls_world_age(), source_mode)
Base.invoke_in_world($(Expr(:$, :typeinf_world_age)), typeinf_ext_toplevel, mi, Base.tls_world_age(), source_mode, Compiler.TRIM_NO)
end
end)
end
Expand Down Expand Up @@ -67,7 +67,7 @@ function bootstrap!()
end
mi = specialize_method(m.method, Tuple{params...}, m.sparams)
#isa_compileable_sig(mi) || println(stderr, "WARNING: inferring `", mi, "` which isn't expected to be called.")
typeinf_ext_toplevel(mi, world, isa_compileable_sig(mi) ? SOURCE_MODE_ABI : SOURCE_MODE_NOT_REQUIRED)
typeinf_ext_toplevel(mi, world, isa_compileable_sig(mi) ? SOURCE_MODE_ABI : SOURCE_MODE_NOT_REQUIRED, TRIM_NO)
end
end
end
Expand Down
19 changes: 11 additions & 8 deletions Compiler/src/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn
block = block_for_inst(ir, idx)
inline_into_block!(state, block)

if !isempty(inlinee_cfg.blocks[1].preds)
if length(inlinee_cfg.blocks[1].preds) > 1
need_split_before = true
else
@assert inlinee_cfg.blocks[1].preds[1] == 0
end

last_block_idx = last(state.cfg.blocks[block].stmts)
if false # TODO: ((idx+1) == last_block_idx && isa(ir[SSAValue(last_block_idx)], GotoNode))
need_split = false
Expand Down Expand Up @@ -166,12 +167,18 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn
end
new_block_range = (length(state.new_cfg_blocks)-length(inlinee_cfg.blocks)+1):length(state.new_cfg_blocks)

# Fixup the edges of the newely added blocks
# Fixup the edges of the newly added blocks
for (old_block, new_block) in enumerate(bb_rename_range)
if old_block != 1 || need_split_before
p = state.new_cfg_blocks[new_block].preds
let bb_rename_range = bb_rename_range
map!(p, p) do old_pred_block
# the meaning of predecessor 0 depends on the block we encounter it:
# - in the first block, it represents the function entry and so needs to be re-mapped
if old_block == 1 && old_pred_block == 0
return first(bb_rename_range) - 1
end
# - elsewhere, it represents external control-flow from a caught exception which is un-affected by inlining
return old_pred_block == 0 ? 0 : bb_rename_range[old_pred_block]
end
end
Expand All @@ -186,10 +193,6 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn
end
end

if need_split_before
push!(state.new_cfg_blocks[first(bb_rename_range)].preds, first(bb_rename_range)-1)
end

any_edges = false
for (old_block, new_block) in enumerate(bb_rename_range)
if (length(state.new_cfg_blocks[new_block].succs) == 0)
Expand Down Expand Up @@ -399,7 +402,7 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
else
bb_offset, post_bb_id = popfirst!(todo_bbs)
# This implements the need_split_before flag above
need_split_before = !isempty(item.ir.cfg.blocks[1].preds)
need_split_before = length(item.ir.cfg.blocks[1].preds) > 1
if need_split_before
finish_current_bb!(compact, 0)
end
Expand Down
3 changes: 3 additions & 0 deletions Compiler/src/ssair/ir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ function compute_basic_blocks(stmts::Vector{Any})
end
# Compute successors/predecessors
for (num, b) in enumerate(blocks)
if b.stmts.start == 1
push!(b.preds, 0) # the entry block has a virtual predecessor
end
terminator = stmts[last(b.stmts)]
if isa(terminator, ReturnNode)
# return never has any successors
Expand Down
17 changes: 9 additions & 8 deletions Compiler/src/stmtinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,20 @@ end
add_edges_impl(edges::Vector{Any}, info::MethodMatchInfo) = _add_edges_impl(edges, info)
function _add_edges_impl(edges::Vector{Any}, info::MethodMatchInfo, mi_edge::Bool=false)
if !fully_covering(info)
# add legacy-style missing backedge info also
exists = false
for i in 2:length(edges)
if edges[i] === info.mt && edges[i-1] == info.atype
if edges[i] === Core.GlobalMethods && edges[i-1] == info.atype
exists = true
break
end
end
if !exists
push!(edges, info.atype)
push!(edges, info.mt)
push!(edges, Core.GlobalMethods)
end
end
nmatches = length(info.results)
if nmatches == length(info.edges) == 1
if nmatches == length(info.edges) == 1 && fully_covering(info)
# try the optimized format for the representation, if possible and applicable
# if this doesn't succeed, the backedge will be less precise,
# but the forward edge will maintain the precision
Expand All @@ -79,13 +78,15 @@ function _add_edges_impl(edges::Vector{Any}, info::MethodMatchInfo, mi_edge::Boo
end
end
# add check for whether this lookup already existed in the edges list
# encode nmatches as negative if fully_covers is false
encoded_nmatches = fully_covering(info) ? nmatches : -nmatches
for i in 1:length(edges)
if edges[i] === nmatches && edges[i+1] == info.atype
if edges[i] === encoded_nmatches && edges[i+1] == info.atype
# TODO: must also verify the CodeInstance match too
return nothing
end
end
push!(edges, nmatches, info.atype)
push!(edges, encoded_nmatches, info.atype)
for i = 1:nmatches
edge = info.edges[i]
m = info.results[i]
Expand All @@ -102,7 +103,7 @@ function add_one_edge!(edges::Vector{Any}, edge::MethodInstance)
i = 1
while i <= length(edges)
edgeᵢ = edges[i]
edgeᵢ isa Int && (i += 2 + edgeᵢ; continue)
edgeᵢ isa Int && (i += 2 + abs(edgeᵢ); continue)
edgeᵢ isa CodeInstance && (edgeᵢ = get_ci_mi(edgeᵢ))
edgeᵢ isa MethodInstance || (i += 1; continue)
if edgeᵢ === edge && !(i > 1 && edges[i-1] isa Type)
Expand All @@ -117,7 +118,7 @@ function add_one_edge!(edges::Vector{Any}, edge::CodeInstance)
i = 1
while i <= length(edges)
edgeᵢ_orig = edgeᵢ = edges[i]
edgeᵢ isa Int && (i += 2 + edgeᵢ; continue)
edgeᵢ isa Int && (i += 2 + abs(edgeᵢ); continue)
edgeᵢ isa CodeInstance && (edgeᵢ = get_ci_mi(edgeᵢ))
edgeᵢ isa MethodInstance || (i += 1; continue)
if edgeᵢ === edge.def && !(i > 1 && edges[i-1] isa Type)
Expand Down
8 changes: 4 additions & 4 deletions Compiler/src/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ end
return isdefined_tfunc(𝕃, arg1, sym)
end
@nospecs function isdefined_tfunc(𝕃::AbstractLattice, arg1, sym)
if arg1 isa MustAlias
arg1 = widenmustalias(arg1)
end
arg1t = arg1 isa Const ? typeof(arg1.val) : isconstType(arg1) ? typeof(arg1.parameters[1]) : widenconst(arg1)
a1 = unwrap_unionall(arg1t)
if isa(a1, DataType) && !isabstracttype(a1)
Expand Down Expand Up @@ -3156,15 +3159,12 @@ function _hasmethod_tfunc(interp::AbstractInterpreter, argtypes::Vector{Any}, sv
isdispatchelem(ft) || return CallMeta(Bool, Any, Effects(), NoCallInfo()) # check that we might not have a subtype of `ft` at runtime, before doing supertype lookup below
types = rewrap_unionall(Tuple{ft, unwrapped.parameters...}, types)::Type
end
mt = ccall(:jl_method_table_for, Any, (Any,), types)
if !isa(mt, MethodTable)
return CallMeta(Bool, Any, EFFECTS_THROWS, NoCallInfo())
end
match, valid_worlds = findsup(types, method_table(interp))
update_valid_age!(sv, valid_worlds)
if match === nothing
rt = Const(false)
vresults = MethodLookupResult(Any[], valid_worlds, true)
mt = Core.GlobalMethods
vinfo = MethodMatchInfo(vresults, mt, types, false) # XXX: this should actually be an info with invoke-type edge
else
rt = Const(true)
Expand Down
Loading