Skip to content

Commit 2b7a874

Browse files
authored
Backports for julia 1.11.5 (#57714)
2 parents 8561cc3 + eccd25a commit 2b7a874

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1252
-925
lines changed

THIRDPARTY.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ for exceptions.
66
- [crc32c.c](https://stackoverflow.com/questions/17645167/implementing-sse-4-2s-crc32c-in-software) (CRC-32c checksum code by Mark Adler) [[ZLib](https://opensource.org/licenses/Zlib)].
77
- [LDC](https://github.com/ldc-developers/ldc/blob/master/LICENSE) (for ccall/cfunction ABI definitions) [BSD-3]. The portion of code that Julia uses from LDC is [BSD-3] licensed.
88
- [LLVM](https://releases.llvm.org/3.9.0/LICENSE.TXT) (for parts of src/disasm.cpp) [UIUC]
9-
- [MINGW](https://sourceforge.net/p/mingw/mingw-org-wsl/ci/legacy/tree/mingwrt/mingwex/dirname.c) (for dirname implementation on Windows) [MIT]
109
- [NetBSD](https://www.netbsd.org/about/redistribution.html) (for setjmp, longjmp, and strptime implementations on Windows) [BSD-3]
1110
- [Python](https://docs.python.org/3/license.html) (for strtod implementation on Windows) [PSF]
1211
- [FEMTOLISP](https://github.com/JeffBezanson/femtolisp) [BSD-3]

base/abstractarray.jl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3654,7 +3654,31 @@ function _keepat!(a::AbstractVector, m::AbstractVector{Bool})
36543654
deleteat!(a, j:lastindex(a))
36553655
end
36563656

3657-
## 1-d circshift ##
3657+
"""
3658+
circshift!(a::AbstractVector, shift::Integer)
3659+
3660+
Circularly shift, or rotate, the data in vector `a` by `shift` positions.
3661+
3662+
# Examples
3663+
3664+
```jldoctest
3665+
julia> circshift!([1, 2, 3, 4, 5], 2)
3666+
5-element Vector{Int64}:
3667+
4
3668+
5
3669+
1
3670+
2
3671+
3
3672+
3673+
julia> circshift!([1, 2, 3, 4, 5], -2)
3674+
5-element Vector{Int64}:
3675+
3
3676+
4
3677+
5
3678+
1
3679+
2
3680+
```
3681+
"""
36583682
function circshift!(a::AbstractVector, shift::Integer)
36593683
n = length(a)
36603684
n == 0 && return a

base/array.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ function append! end
13201320

13211321
function append!(a::Vector{T}, items::Union{AbstractVector{<:T},Tuple}) where T
13221322
items isa Tuple && (items = map(x -> convert(T, x), items))
1323-
n = length(items)
1323+
n = Int(length(items))::Int
13241324
_growend!(a, n)
13251325
copyto!(a, length(a)-n+1, items, firstindex(items), n)
13261326
return a
@@ -1444,7 +1444,8 @@ julia> a[1:6]
14441444
1
14451445
```
14461446
"""
1447-
function resize!(a::Vector, nl::Integer)
1447+
function resize!(a::Vector, nl_::Integer)
1448+
nl = Int(nl_)::Int
14481449
l = length(a)
14491450
if nl > l
14501451
_growend!(a, nl-l)

base/cmd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ julia> run(cm)
504504
Process(`echo 1`, ProcessExited(0))
505505
```
506506
"""
507-
macro cmd(str)
507+
macro cmd(str::String)
508508
cmd_ex = shell_parse(str, special=shell_special, filename=String(__source__.file))[1]
509509
return :(cmd_gen($(esc(cmd_ex))))
510510
end

base/compiler/effects.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ is_inaccessiblemem_or_argmemonly(effects::Effects) = effects.inaccessiblememonly
329329

330330
is_consistent_overlay(effects::Effects) = effects.nonoverlayed === CONSISTENT_OVERLAY
331331

332-
# (sync this with codegen.cpp and staticdata.c effects_foldable functions)
333332
function encode_effects(e::Effects)
334333
return ((e.consistent % UInt32) << 0) |
335334
((e.effect_free % UInt32) << 3) |

base/compiler/ssair/passes.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,10 @@ function sroa_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
14801480
used_ssas[x.id] -= 1
14811481
end
14821482
ir = complete(compact)
1483+
# remove any use that has been optimized away by the DCE
1484+
for (intermediaries, defuse) in values(defuses)
1485+
filter!(x -> ir[SSAValue(x.idx)][:stmt] !== nothing, defuse.uses)
1486+
end
14831487
sroa_mutables!(ir, defuses, used_ssas, lazydomtree, inlining)
14841488
return ir
14851489
else

base/exports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ public
10951095
ImmutableDict,
10961096
Lockable,
10971097
OneTo,
1098+
Pairs,
10981099
LogRange,
10991100
UUID,
11001101

base/int.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ ERROR: LoadError: ArgumentError: invalid base 10 digit '.' in "123456789123.4"
647647
[...]
648648
```
649649
"""
650-
macro int128_str(s)
650+
macro int128_str(s::String)
651651
return parse(Int128, s)
652652
end
653653

@@ -667,7 +667,7 @@ ERROR: LoadError: ArgumentError: invalid base 10 digit '-' in "-123456789123"
667667
[...]
668668
```
669669
"""
670-
macro uint128_str(s)
670+
macro uint128_str(s::String)
671671
return parse(UInt128, s)
672672
end
673673

@@ -700,7 +700,7 @@ ERROR: ArgumentError: invalid number format _ for BigInt or BigFloat
700700
depends on the value of the precision at the point when the function is
701701
defined, **not** at the precision at the time when the function is called.
702702
"""
703-
macro big_str(s)
703+
macro big_str(s::String)
704704
message = "invalid number format $s for BigInt or BigFloat"
705705
throw_error = :(throw(ArgumentError($message)))
706706
if '_' in s

base/intfuncs.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,8 @@ function nextpow(a::Real, x::Real)
526526
n = ceil(Integer,log(a, x))
527527
# round-off error of log can go either direction, so need some checks
528528
p = a^(n-1)
529-
x > typemax(p) && throw(DomainError(x,"argument is beyond the range of type of the base"))
529+
hastypemax(typeof(p)) && x > typemax(p) &&
530+
throw(DomainError(x,"argument is beyond the range of type of the base"))
530531
p >= x && return p
531532
wp = a^n
532533
wp > p || throw(OverflowError("result is beyond the range of type of the base"))
@@ -567,9 +568,10 @@ function prevpow(a::T, x::Real) where T <: Real
567568
n = floor(Integer,log(a, x))
568569
# round-off error of log can go either direction, so need some checks
569570
p = a^n
570-
x > typemax(p) && throw(DomainError(x,"argument is beyond the range of type of the base"))
571+
hastypemax(typeof(p)) && x > typemax(p) &&
572+
throw(DomainError(x,"argument is beyond the range of type of the base"))
571573
if a isa Integer
572-
wp, overflow = mul_with_overflow(a, p)
574+
wp, overflow = mul_with_overflow(promote(a, p)...)
573575
wp <= x && !overflow && return wp
574576
else
575577
wp = a^(n+1)
@@ -801,7 +803,7 @@ function append_c_digits(olength::Int, digits::Unsigned, buf, pos::Int)
801803
while i >= 2
802804
d, c = divrem(digits, 0x64)
803805
digits = oftype(digits, d)
804-
@inbounds d100 = _dec_d100[(c % Int) + 1]
806+
@inbounds d100 = _dec_d100[(c % Int)::Int + 1]
805807
@inbounds buf[pos + i - 2] = d100 % UInt8
806808
@inbounds buf[pos + i - 1] = (d100 >> 0x8) % UInt8
807809
i -= 2

base/iobuffer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ function _copyline(out::IO, io::GenericIOBuffer; keep::Bool=false)
615615
data = view(io.data, io.ptr:io.size)
616616
# note: findfirst + copyto! is much faster than a single loop
617617
# except for nout ≲ 20. A single loop is 2x faster for nout=5.
618-
nout = nread = something(findfirst(==(0x0a), data), length(data))
618+
nout = nread = something(findfirst(==(0x0a), data), length(data))::Int
619619
if !keep && nout > 0 && data[nout] == 0x0a
620620
nout -= 1
621621
nout > 0 && data[nout] == 0x0d && (nout -= 1)

base/libdl.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ struct LazyLibraryPath
334334
LazyLibraryPath(pieces::Vector) = new(pieces)
335335
end
336336
LazyLibraryPath(args...) = LazyLibraryPath(collect(args))
337-
Base.string(llp::LazyLibraryPath) = joinpath(string.(llp.pieces)...)::String
337+
Base.string(llp::LazyLibraryPath) = joinpath(String[string(p) for p in llp.pieces])
338338
Base.cconvert(::Type{Cstring}, llp::LazyLibraryPath) = Base.cconvert(Cstring, string(llp))
339339
# Define `print` so that we can wrap this in a `LazyString`
340340
Base.print(io::IO, llp::LazyLibraryPath) = print(io, string(llp))

base/math.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ for f in (:sin, :cos, :tan, :asin, :atan, :acos,
15271527
:exponent, :sqrt, :cbrt, :sinpi, :cospi, :sincospi, :tanpi)
15281528
@eval function ($f)(x::Real)
15291529
xf = float(x)
1530-
x === xf && throw(MethodError($f, (x,)))
1530+
xf isa typeof(x) && throw(MethodError($f, (x,)))
15311531
return ($f)(xf)
15321532
end
15331533
@eval $(f)(::Missing) = missing

base/pcre.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ end
199199
exec(re, subject::Union{String,SubString{String}}, offset, options, match_data) =
200200
_exec(re, subject, offset, options, match_data)
201201
exec(re, subject, offset, options, match_data) =
202-
_exec(re, String(subject), offset, options, match_data)
202+
_exec(re, String(subject)::String, offset, options, match_data)
203203

204204
function _exec(re, subject, offset, options, match_data)
205205
rc = ccall((:pcre2_match_8, PCRE_LIB), Cint,

base/precompilation.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,16 @@ function ExplicitEnv(envpath::String=Base.active_project())
141141

142142
# Extensions
143143
deps_pkg = get(Dict{String, Any}, pkg_info, "extensions")::Dict{String, Any}
144+
deps_pkg_concrete = Dict{String, Vector{String}}()
144145
for (ext, triggers) in deps_pkg
145146
if triggers isa String
146147
triggers = [triggers]
147148
else
148149
triggers = triggers::Vector{String}
149150
end
150-
deps_pkg[ext] = triggers
151+
deps_pkg_concrete[ext] = triggers
151152
end
152-
extensions[m_uuid] = deps_pkg
153+
extensions[m_uuid] = deps_pkg_concrete
153154

154155
# Determine strategy to find package
155156
lookup_strat = begin
@@ -810,8 +811,8 @@ function _precompilepkgs(pkgs::Vector{String},
810811
# window between print cycles
811812
termwidth = displaysize(io)[2] - 4
812813
if !final_loop
813-
str = sprint(io -> show_progress(io, bar; termwidth, carriagereturn=false); context=io)
814-
print(iostr, Base._truncate_at_width_or_chars(true, str, termwidth), "\n")
814+
s = sprint(io -> show_progress(io, bar; termwidth, carriagereturn=false); context=io)
815+
print(iostr, Base._truncate_at_width_or_chars(true, s, termwidth), "\n")
815816
end
816817
for pkg_config in pkg_queue_show
817818
dep, config = pkg_config

base/regex.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ mutable struct Regex <: AbstractPattern
3939
end
4040
re = compile(new(pattern, compile_options, match_options, C_NULL))
4141
finalizer(re) do re
42-
re.regex == C_NULL || PCRE.free_re(re.regex)
42+
# don't free during exit because tasks may still be running and
43+
# using it. Issue #57817. During sysimage creation _atexit_hooks_finished
44+
# is not defined but threads aren't running so just always run
45+
during_exit = @isdefined(_atexit_hooks_finished) && _atexit_hooks_finished
46+
if re.regex != C_NULL && !during_exit
47+
PCRE.free_re(re.regex)
48+
end
4349
end
4450
re
4551
end

base/shell.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ function shell_escape_csh(io::IO, args::AbstractString...)
342342
end
343343
shell_escape_csh(args::AbstractString...) =
344344
sprint(shell_escape_csh, args...;
345-
sizehint = sum(sizeof.(args)) + length(args) * 3)
345+
sizehint = sum(sizeof, args) + length(args) * 3)
346346

347347
"""
348348
shell_escape_wincmd(s::AbstractString)
@@ -492,4 +492,4 @@ function escape_microsoft_c_args(io::IO, args::AbstractString...)
492492
end
493493
escape_microsoft_c_args(args::AbstractString...) =
494494
sprint(escape_microsoft_c_args, args...;
495-
sizehint = (sum(sizeof.(args)) + 3*length(args)))
495+
sizehint = (sum(sizeof, args) + 3*length(args)))

base/strings/annotated.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ promote_rule(::Type{<:AnnotatedString}, ::Type{<:AbstractString}) = AnnotatedStr
147147

148148
## AbstractString interface ##
149149

150-
ncodeunits(s::AnnotatedString) = ncodeunits(s.string)
150+
ncodeunits(s::AnnotatedString) = ncodeunits(s.string)::Int
151151
codeunits(s::AnnotatedString) = codeunits(s.string)
152152
codeunit(s::AnnotatedString) = codeunit(s.string)
153153
codeunit(s::AnnotatedString, i::Integer) = codeunit(s.string, i)
154-
isvalid(s::AnnotatedString, i::Integer) = isvalid(s.string, i)
154+
isvalid(s::AnnotatedString, i::Integer) = isvalid(s.string, i)::Bool
155155
@propagate_inbounds iterate(s::AnnotatedString, i::Integer=firstindex(s)) =
156156
if i <= lastindex(s.string); (s[i], nextind(s, i)) end
157157
eltype(::Type{<:AnnotatedString{S}}) where {S} = AnnotatedChar{eltype(S)}

base/strings/basic.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,11 @@ prevind(s::AbstractString, i::Int) = prevind(s, i, 1)
512512

513513
function prevind(s::AbstractString, i::Int, n::Int)
514514
n < 0 && throw(ArgumentError("n cannot be negative: $n"))
515-
z = ncodeunits(s) + 1
515+
z = ncodeunits(s)::Int + 1
516516
@boundscheck 0 < i z || throw(BoundsError(s, i))
517-
n == 0 && return thisind(s, i) == i ? i : string_index_err(s, i)
517+
n == 0 && return thisind(s, i)::Int == i ? i : string_index_err(s, i)
518518
while n > 0 && 1 < i
519-
@inbounds n -= isvalid(s, i -= 1)
519+
@inbounds n -= isvalid(s, i -= 1)::Bool
520520
end
521521
return i - n
522522
end
@@ -571,11 +571,11 @@ nextind(s::AbstractString, i::Int) = nextind(s, i, 1)
571571

572572
function nextind(s::AbstractString, i::Int, n::Int)
573573
n < 0 && throw(ArgumentError("n cannot be negative: $n"))
574-
z = ncodeunits(s)
574+
z = ncodeunits(s)::Int
575575
@boundscheck 0 i z || throw(BoundsError(s, i))
576-
n == 0 && return thisind(s, i) == i ? i : string_index_err(s, i)
576+
n == 0 && return thisind(s, i)::Int == i ? i : string_index_err(s, i)
577577
while n > 0 && i < z
578-
@inbounds n -= isvalid(s, i += 1)
578+
@inbounds n -= isvalid(s, i += 1)::Bool
579579
end
580580
return i + n
581581
end

base/strings/io.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ julia> v[2]
577577
0x32
578578
```
579579
"""
580-
macro b_str(s)
580+
macro b_str(s::String)
581581
v = codeunits(unescape_string(s))
582582
QuoteNode(v)
583583
end

base/summarysize.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,8 @@ function (ss::SummarySize)(obj::GenericMemory)
149149
datakey = unsafe_convert(Ptr{Cvoid}, obj)
150150
if !haskey(ss.seen, datakey)
151151
ss.seen[datakey] = true
152-
dsize = sizeof(obj)
152+
size += sizeof(obj)
153153
T = eltype(obj)
154-
if isbitsunion(T)
155-
# add 1 union selector byte for each element
156-
dsize += length(obj)
157-
end
158-
size += dsize
159154
if !isempty(obj) && T !== Symbol && (!Base.allocatedinline(T) || (T isa DataType && !Base.datatype_pointerfree(T)))
160155
push!(ss.frontier_x, obj)
161156
push!(ss.frontier_i, 1)

deps/checksums/Pkg-2eb8ae5b8f421fc77295f9cf382132d39e14d16f.tar.gz/md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps/checksums/Pkg-2eb8ae5b8f421fc77295f9cf382132d39e14d16f.tar.gz/sha512

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b5b6cc2e7a1b6401d102f51abb4ae4d5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2a58eab12df4070a2a002c6e52fbf49e6c445fb973dc044e30332052cfb6089de12525c8ce2f3f5dd5651e0305477fbbf6b8e063c78a6ddc96c52254f5364c5a

0 commit comments

Comments
 (0)