Skip to content
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

Backports release 1.12 #57536

Open
wants to merge 68 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
68 commits
Select commit Hold shift + click to select a range
bec9235
build: fix makefile rules and windows path separator used in build (#…
vtjnash Feb 21, 2025
d3499d0
strip Module filename from metadata (#57499)
vtjnash Feb 22, 2025
b565c28
`Base.summarysize` for `Memory` with `Union` (#57508)
PatrickHaecker Feb 23, 2025
d04631d
don't mutate globals when constructing `Rational` from `AbstractIrrat…
nsajko Feb 25, 2025
92396aa
[Compiler] begin new approach to verify --trim output (#57530)
vtjnash Feb 26, 2025
10d75d2
[Compiler] fix some cycle_fix_limited usage (#57545)
vtjnash Feb 27, 2025
828c7cc
some updates for trimming (#57531)
JeffBezanson Feb 27, 2025
c5d0b67
Bump JuliaSyntaxHighlighting (#57526)
tecosaur Feb 27, 2025
c450cff
Docs: `circshift!(::AbstractVector, ::Integer)` (#57539)
barucden Feb 27, 2025
e2884bc
lowering: Allow chaining of `>:` in `where` (#57554)
mlechu Feb 27, 2025
e878f5c
bpart: Check whether the replaced binding is a type before assuming (…
Keno Feb 28, 2025
c9d2a27
Walk to imports in `isconst(::GlobalRef)` (#57563)
Keno Feb 28, 2025
0a8b382
Always disallow assignments to constants (#57567)
Keno Feb 28, 2025
5323469
Group import hints (#56753)
ajwheeler Feb 28, 2025
87d9c23
Remove `jl_init__threading` and `jl_init_with_image__threading` (#57561)
topolarity Feb 28, 2025
d271805
Make no-body `function` declaration implicitly `global` (#57562)
Keno Mar 1, 2025
66085c5
avoid overflow on functionality to print backtrace of safepoint strag…
d-netto Mar 1, 2025
e661b5f
`Base.Precompilation.ExplicitEnv`: handle type instability better in …
nsajko Mar 2, 2025
e9126d7
cleanup old builtins (#57532)
vtjnash Mar 2, 2025
38644b3
strings: type assert in the generic `nextind`, `prevind` methods (#57…
nsajko Mar 3, 2025
4942b1c
`AnnotatedString`: add concrete type asserts to `isvalid`, `ncodeunit…
nsajko Mar 3, 2025
4eaae59
`Base`: `power_by_squaring`: don't require `one` (#57590)
nsajko Mar 3, 2025
ad92902
Precompile Markdown parsing AND printing (#55752)
PallHaraldsson Mar 4, 2025
b3c81e9
bpart: Also partition ->deprecated (#57449)
Keno Feb 28, 2025
855807c
bpart: Allow inference/codegen to merge multiple partitions (#57602)
Keno Mar 2, 2025
7cf1db3
bpart: Rename partition flags, turn binding flags atomic (#57614)
Keno Mar 3, 2025
686c917
Align module base between invalidation and edge tracking (#57625)
Keno Mar 4, 2025
10f5d44
[1.12] Add PR number to `gc_safe` NEWS entry (#57682)
christiangnrd Mar 8, 2025
8d76a67
Add missing arg in TOML `printvalue` (#57584)
qiaojunfeng Mar 5, 2025
cf69717
Compiler: Fix pre-compilation as separate package (#57650)
topolarity Mar 6, 2025
1679d93
Intersect: try normal+reverse+existential subtyping during intersecti…
N5N3 Mar 6, 2025
9bac7e7
Fix julia.h for use in MSVC (#57654)
barche Mar 7, 2025
c0bf26a
lock: Specialize `OncePerX` more aggressively (#57660)
topolarity Mar 7, 2025
8bfb658
trimming: improve output on failure (#57657)
topolarity Mar 7, 2025
36986a0
typeinfer: Add `force_enable_inference` to override Module-level infe…
topolarity Mar 7, 2025
0e93f12
Compiler: `abstract_apply`: declare type of two closure captures (#57…
nsajko Mar 10, 2025
c04db34
`Base`: `append!`, `resize!`: convert length to `Int` before passing …
nsajko Mar 11, 2025
d8af2ed
Compiler/ssair/passes: `_lift_svec_ref`: improve type stability (#57633)
nsajko Mar 11, 2025
1ad2982
Libdl: Improve inference for `string(::LazyLibraryPath)` (#57721)
topolarity Mar 11, 2025
7e0392d
fix alignment computation for nested objects (#57722)
vtjnash Mar 11, 2025
21d4472
Libdl: Store path contents as `Tuple` instead of `Vector` (#57734)
topolarity Mar 12, 2025
c2398b4
type assert `Core.SimpleVector` in `typejoin_union_tuple` (#57631)
nsajko Mar 12, 2025
c8fe2f5
errorshow: typeassert `::SimpleVector` in `_collapse_repeated_frames`…
nsajko Mar 12, 2025
1692eb7
Avoid requiring the REPL to be loaded to show error hints for undefin…
KristofferC Mar 12, 2025
5f85ec3
inference: exclude uncached frames from callstack (#57743)
vtjnash Mar 13, 2025
c4b667d
remove old cruft from jl_set_typeinf_func (#57760)
vtjnash Mar 14, 2025
31d998e
[docs] Clarify that Float16 is supported natively when possible (#57725)
giordano Mar 15, 2025
1de014a
lowering: Don't closure-convert in `import` or `using` (#57774)
mlechu Mar 15, 2025
4a420a1
fix missing `!` in a strip-metadata case (#57778)
JeffBezanson Mar 15, 2025
dd14c58
print admonition for auto-import only once per module (#57775)
vtjnash Mar 15, 2025
02b8670
enable JuliaSyntax parser for user code in juliac (#57777)
JeffBezanson Mar 15, 2025
84bc0c6
Bugfix: String indexing in big_str macro (#57621)
jakobnissen Mar 17, 2025
2916acd
fix special function `::Real` fallback stack overflow (#57790)
nsajko Mar 17, 2025
09586ff
stackwalk: fix heuristic termination (#57801)
vtjnash Mar 17, 2025
65b5aa7
Fix fptrunc Float64 -> Float16 rounding through Float32 (#57809)
xal-0 Mar 18, 2025
3778b80
add missing wb in jl_maybe_reresolve_implicit (#57804)
vtjnash Mar 19, 2025
59ad091
Fix OncePerThread issue when building a sysimage using the current sy…
gbaraldi Mar 20, 2025
2a04708
Fix error message when using `const` inside a function, require the L…
vtjnash Mar 20, 2025
02e5c83
Fix package precompilation (PrecompileTools) (#57828)
timholy Mar 20, 2025
ef270a4
restrict dispatch of some custrom string macros to `String` (#57781)
nsajko Mar 20, 2025
2294722
Respect JULIA_CPU_TARGET when doing trimming (#57373)
gbaraldi Feb 12, 2025
6f34f91
trimming: Avoid `--strip-ir` when compiling with `--trim=no` (#57659)
topolarity Mar 7, 2025
e342f1c
trimming: Avoid `using` indirectly-loaded packages (#57589)
topolarity Mar 7, 2025
4652a09
trimming: Locate package modules by PkgId (#57672)
topolarity Mar 8, 2025
5e8ac85
[internals] add time metrics for every CodeInstance (#57074)
vtjnash Mar 17, 2025
210288b
Mark UInt8 field as UInt8 in CodInstance (#57822)
gbaraldi Mar 20, 2025
8cb30fa
trimming: Restore JLL support (#57587)
IanButterworth Mar 11, 2025
f851c82
better behaved loading errors (#57727)
vtjnash Mar 14, 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
33 changes: 19 additions & 14 deletions Compiler/src/Compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ using Core: ABIOverride, Builtin, CodeInstance, IntrinsicFunction, MethodInstanc

using Base
using Base: @_foldable_meta, @_gc_preserve_begin, @_gc_preserve_end, @nospecializeinfer,
BINDING_KIND_GLOBAL, BINDING_KIND_UNDEF_CONST, BINDING_KIND_BACKDATED_CONST, BINDING_KIND_DECLARED,
PARTITION_KIND_GLOBAL, PARTITION_KIND_UNDEF_CONST, PARTITION_KIND_BACKDATED_CONST, PARTITION_KIND_DECLARED,
PARTITION_FLAG_DEPWARN,
Base, BitVector, Bottom, Callable, DataTypeFieldDesc,
EffectsOverride, Filter, Generator, IteratorSize, JLOptions, NUM_EFFECTS_OVERRIDES,
OneTo, Ordering, RefValue, SizeUnknown, _NAMEDTUPLE_NAME,
Expand Down Expand Up @@ -188,21 +189,25 @@ macro __SOURCE_FILE__()
return QuoteNode(__source__.file::Symbol)
end

module IRShow end
function load_irshow!()
if isdefined(Base, :end_base_include)
# This code path is exclusively for Revise, which may want to re-run this
# after bootstrap.
include(IRShow, Base.joinpath(Base.dirname(Base.String(@__SOURCE_FILE__)), "ssair/show.jl"))
else
module IRShow end # relies on string and IO operations defined in Base
baremodule TrimVerifier end # relies on IRShow, so define this afterwards

if isdefined(Base, :end_base_include)
# When this module is loaded as the standard library, include these files as usual
include(IRShow, "ssair/show.jl")
include(TrimVerifier, "verifytrim.jl")
else
function load_irshow!()
Base.delete_method(Base.which(verify_typeinf_trim, (IO, Vector{Any}, Bool)),)
include(IRShow, "ssair/show.jl")
include(TrimVerifier, "verifytrim.jl")
end
end
if !isdefined(Base, :end_base_include)
# During bootstrap, skip including this file and defer it to base/show.jl to include later
else
# When this module is loaded as the standard library, include this file as usual
load_irshow!()
function verify_typeinf_trim(io::IO, codeinfos::Vector{Any}, onlywarn::Bool)
# stub implementation
msg = "--trim verifier not defined"
onlywarn ? println(io, msg) : error(msg)
end
# During bootstrap, skip including these files and defer to base/show.jl to include it later
end

end # baremodule Compiler
Expand Down
282 changes: 180 additions & 102 deletions Compiler/src/abstractinterpretation.jl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Compiler/src/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function bootstrap!()
end
end
end
codeinfos = typeinf_ext_toplevel(methods, [world], false)
codeinfos = typeinf_ext_toplevel(methods, [world], TRIM_NO)
for i = 1:2:length(codeinfos)
ci = codeinfos[i]::CodeInstance
src = codeinfos[i + 1]::CodeInfo
Expand Down
8 changes: 8 additions & 0 deletions Compiler/src/cicache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ function intersect(a::WorldRange, b::WorldRange)
return ret
end

function union(a::WorldRange, b::WorldRange)
if b.min_world < a.min_world
(b, a) = (a, b)
end
@assert a.max_world >= b.min_world - 1
return WorldRange(a.min_world, b.max_world)
end

"""
struct WorldView

Expand Down
3 changes: 2 additions & 1 deletion Compiler/src/inferenceresult.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ function cache_lookup(𝕃::AbstractLattice, mi::MethodInstance, given_argtypes:
method = mi.def::Method
nargtypes = length(given_argtypes)
for cached_result in cache
cached_result.linfo === mi || @goto next_cache
cached_result.tombstone && continue # ignore deleted entries (due to LimitedAccuracy)
cached_result.linfo === mi || continue
cache_argtypes = cached_result.argtypes
@assert length(cache_argtypes) == nargtypes "invalid `cache_argtypes` for `mi`"
cache_overridden_by_const = cached_result.overridden_by_const::BitVector
Expand Down
27 changes: 19 additions & 8 deletions Compiler/src/inferencestate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ mutable struct InferenceState

# IPO tracking of in-process work, shared with all frames given AbstractInterpreter
callstack #::Vector{AbsIntState}
parentid::Int # index into callstack of the parent frame that originally added this frame (call frame_parent to extract the current parent of the SCC)
parentid::Int # index into callstack of the parent frame that originally added this frame (call cycle_parent to extract the current parent of the SCC)
frameid::Int # index into callstack at which this object is found (or zero, if this is not a cached frame and has no parent)
cycleid::Int # index into the callstack of the topmost frame in the cycle (all frames in the same cycle share the same cycleid)

Expand All @@ -302,6 +302,10 @@ mutable struct InferenceState
bestguess #::Type
exc_bestguess
ipo_effects::Effects
time_start::UInt64
time_caches::Float64
time_paused::UInt64
time_self_ns::UInt64

#= flags =#
# Whether to restrict inference of abstract call sites to avoid excessive work
Expand Down Expand Up @@ -392,6 +396,7 @@ mutable struct InferenceState
currbb, currpc, ip, handler_info, ssavalue_uses, bb_vartables, bb_saw_latestworld, ssavaluetypes, ssaflags, edges, stmt_info,
tasks, pclimitations, limitations, cycle_backedges, callstack, parentid, frameid, cycleid,
result, unreachable, bestguess, exc_bestguess, ipo_effects,
_time_ns(), 0.0, 0, 0,
restrict_abstract_call_sites, cache_mode, insert_coverage,
interp)

Expand Down Expand Up @@ -815,6 +820,8 @@ mutable struct IRInterpretationState
const mi::MethodInstance
world::WorldWithRange
curridx::Int
time_caches::Float64
time_paused::UInt64
const argtypes_refined::Vector{Bool}
const sptypes::Vector{VarState}
const tpdum::TwoPhaseDefUseMap
Expand Down Expand Up @@ -849,7 +856,8 @@ mutable struct IRInterpretationState
tasks = WorkThunk[]
edges = Any[]
callstack = AbsIntState[]
return new(spec_info, ir, mi, WorldWithRange(world, valid_worlds), curridx, argtypes_refined, ir.sptypes, tpdum,
return new(spec_info, ir, mi, WorldWithRange(world, valid_worlds),
curridx, 0.0, 0, argtypes_refined, ir.sptypes, tpdum,
ssa_refined, lazyreachability, tasks, edges, callstack, 0, 0)
end
end
Expand Down Expand Up @@ -908,14 +916,17 @@ function frame_module(sv::AbsIntState)
return def.module
end

function frame_parent(sv::InferenceState)
frame_parent(sv::AbsIntState) = sv.parentid == 0 ? nothing : (sv.callstack::Vector{AbsIntState})[sv.parentid]

function cycle_parent(sv::InferenceState)
sv.parentid == 0 && return nothing
callstack = sv.callstack::Vector{AbsIntState}
sv = callstack[sv.cycleid]::InferenceState
sv.parentid == 0 && return nothing
return callstack[sv.parentid]
end
frame_parent(sv::IRInterpretationState) = sv.parentid == 0 ? nothing : (sv.callstack::Vector{AbsIntState})[sv.parentid]
cycle_parent(sv::IRInterpretationState) = frame_parent(sv)


# add the orphan child to the parent and the parent to the child
function assign_parentchild!(child::InferenceState, parent::AbsIntState)
Expand Down Expand Up @@ -986,12 +997,12 @@ ascending the tree from the given `AbsIntState`).
Note that cycles may be visited in any order.
"""
struct AbsIntStackUnwind
sv::AbsIntState
callstack::Vector{AbsIntState}
AbsIntStackUnwind(sv::AbsIntState) = new(sv.callstack::Vector{AbsIntState})
end
iterate(unw::AbsIntStackUnwind) = (unw.sv, length(unw.sv.callstack::Vector{AbsIntState}))
function iterate(unw::AbsIntStackUnwind, frame::Int)
function iterate(unw::AbsIntStackUnwind, frame::Int=length(unw.callstack))
frame == 0 && return nothing
return ((unw.sv.callstack::Vector{AbsIntState})[frame], frame - 1)
return (unw.callstack[frame], frame - 1)
end

struct AbsIntCycle
Expand Down
3 changes: 2 additions & 1 deletion Compiler/src/ssair/irinterp.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

function collect_limitations!(@nospecialize(typ), ::IRInterpretationState)
@assert !isa(typ, LimitedAccuracy) "irinterp is unable to handle heavy recursion"
@assert !isa(typ, LimitedAccuracy) "irinterp is unable to handle heavy recursion correctly"
return typ
end

Expand Down Expand Up @@ -212,6 +212,7 @@ function reprocess_instruction!(interp::AbstractInterpreter, inst::Instruction,
else
rt = argextype(stmt, irsv.ir)
end
@assert !(rt isa LimitedAccuracy)
if rt !== nothing
if has_flag(inst, IR_FLAG_UNUSED)
# Don't bother checking the type if we know it's unused
Expand Down
16 changes: 9 additions & 7 deletions Compiler/src/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1027,17 +1027,19 @@ end
sig = sig.body
isa(sig, DataType) || return nothing
sig.name === Tuple.name || return nothing
length(sig.parameters) >= 1 || return nothing
sig_parameters = sig.parameters::SimpleVector
length_sig_parameters = length(sig_parameters)
length_sig_parameters >= 1 || return nothing

i = let sig=sig
findfirst(j::Int->has_typevar(sig.parameters[j], tvar), 1:length(sig.parameters))
function has_typevar_closure(j::Int)
has_typevar(sig_parameters[j], tvar)
end

i = findfirst(has_typevar_closure, 1:length_sig_parameters)
i === nothing && return nothing
let sig=sig
any(j::Int->has_typevar(sig.parameters[j], tvar), i+1:length(sig.parameters))
end && return nothing
any(has_typevar_closure, i+1:length_sig_parameters) && return nothing

arg = sig.parameters[i]
arg = sig_parameters[i]

rarg = def.args[2 + i]
isa(rarg, SSAValue) || return nothing
Expand Down
2 changes: 1 addition & 1 deletion Compiler/src/ssair/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function builtin_call_has_dispatch(
return true
end
end
elseif (f === Core._apply_pure || f === Core._call_in_world || f === Core._call_in_world_total || f === Core._call_latest)
elseif (f === Core.invoke_in_world || f === Core._call_in_world_total || f === Core.invokelatest)
# These apply-like builtins are effectively dynamic calls
return true
end
Expand Down
19 changes: 8 additions & 11 deletions Compiler/src/ssair/verify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,14 @@ function check_op(ir::IRCode, domtree::DomTree, @nospecialize(op), use_bb::Int,
raise_error()
end
elseif isa(op, GlobalRef)
bpart = lookup_binding_partition(min_world(ir.valid_worlds), op)
while is_some_imported(binding_kind(bpart)) && max_world(ir.valid_worlds) <= bpart.max_world
imported_binding = partition_restriction(bpart)::Core.Binding
bpart = lookup_binding_partition(min_world(ir.valid_worlds), imported_binding)
end
if (!is_defined_const_binding(binding_kind(bpart)) || (bpart.max_world < max_world(ir.valid_worlds))) &&
(op.mod !== Core) && (op.mod !== Base)
# Core and Base are excluded because the frontend uses them for intrinsics, etc.
# TODO: Decide which way to go with these.
@verify_error "Unbound or partitioned GlobalRef not allowed in value position"
raise_error()
if op.mod !== Core && op.mod !== Base
(valid_worlds, alldef) = scan_leaf_partitions(nothing, op, WorldWithRange(min_world(ir.valid_worlds), ir.valid_worlds)) do _, _, bpart
is_defined_const_binding(binding_kind(bpart))
end
if !alldef || max_world(valid_worlds) < max_world(ir.valid_worlds) || min_world(valid_worlds) > min_world(ir.valid_worlds)
@verify_error "Unbound or partitioned GlobalRef not allowed in value position"
raise_error()
end
end
elseif isa(op, Expr)
# Only Expr(:boundscheck) is allowed in value position
Expand Down
2 changes: 0 additions & 2 deletions Compiler/src/stmtinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,7 @@ perform such accesses.
"""
struct GlobalAccessInfo <: CallInfo
b::Core.Binding
bpart::Core.BindingPartition
end
GlobalAccessInfo(::Core.Binding, ::Nothing) = NoCallInfo()
function add_edges_impl(edges::Vector{Any}, info::GlobalAccessInfo)
push!(edges, info.b)
end
Expand Down
Loading