Skip to content

Commit 1391444

Browse files
authored
Backports release 1.10 (#51563)
Backported PRs: - [x] #50932 <!-- types: fix hash values of Vararg --> - [x] #50975 <!-- Use rr-safe `nopl; rdtsc` sequence --> - [x] #50989 <!-- fix incorrect results in `expm1(::Union{Float16, Float32})` --> - [x] #51284 <!-- Avoid infinite loop when doing SIGTRAP in arm64-apple --> - [x] #51332 <!-- Add s4 field to Xoshiro --> - [x] #51397 <!-- call Pkg precompile hook in latest world --> - [x] #51405 <!-- Remove fallback that assigns a module to inlined frames. --> - [x] #51491 <!-- Throw clearer ArgumentError for strip with two string args --> - [x] #51531 <!-- fix `_tryonce_download_from_cache` (busybox.exe download error) --> - [x] #51541 <!-- Fix string index error in tab completion code --> - [x] #51530 <!-- Don't mark nonlocal symbols as hidden --> - [x] #51557 <!-- Fix last startup & shutdown precompiles --> - [x] #51512 <!-- avoid limiting Type{Any} to Type --> - [x] #51595 <!-- reset `maxprobe` on `empty!` --> - [x] #51582 <!-- Aggressive constprop in LinearAlgebra.wrap --> - [x] #51592 <!-- correctly track element pointer in heap snapshot --> - [x] #51326 <!-- complete false & true more generally as vals --> - [x] #51376 <!-- make `hash(::Xoshiro)` compatible with `==` --> - [x] #51557 <!-- Fix last startup & shutdown precompiles --> - [x] #51845 - [x] #51840 - [x] #50663 <!-- Fix Expr(:loopinfo) codegen --> - [x] #51863 <!-- LLVM 15.0.7-9 --> Contains multiple commits, manual intervention needed: - [ ] #51035 <!-- refactor GC scanning code to reflect jl_binding_t are now first class --> - [ ] #51092 <!-- inference: fix bad effects for recursion --> Non-merged PRs with backport label: - [ ] #51479 <!-- prevent code loading from lookin in the versioned environment when building Julia --> - [ ] #51414 <!-- improvements on GC scheduler shutdown --> - [ ] #51366 <!-- Handle infix operators in REPL completion --> - [ ] #50919 <!-- Code loading: do the "skipping mtime check for stdlib" check regardless of the value of `ispath(f)` --> - [ ] #50824 <!-- Add some aliasing warnings to docstrings for mutating functions in Base --> - [ ] #49805 <!-- Limit TimeType subtraction to AbstractDateTime -->
2 parents 45461be + 81d8c12 commit 1391444

File tree

87 files changed

+1392
-1234
lines changed

Some content is hidden

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

87 files changed

+1392
-1234
lines changed

base/abstractarray.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,17 +1811,16 @@ function __cat_offset1!(A, shape, catdims, offsets, x)
18111811
inds = ntuple(length(offsets)) do i
18121812
(i <= length(catdims) && catdims[i]) ? offsets[i] .+ cat_indices(x, i) : 1:shape[i]
18131813
end
1814-
if x isa AbstractArray
1815-
A[inds...] = x
1816-
else
1817-
fill!(view(A, inds...), x)
1818-
end
1814+
_copy_or_fill!(A, inds, x)
18191815
newoffsets = ntuple(length(offsets)) do i
18201816
(i <= length(catdims) && catdims[i]) ? offsets[i] + cat_size(x, i) : offsets[i]
18211817
end
18221818
return newoffsets
18231819
end
18241820

1821+
_copy_or_fill!(A, inds, x) = fill!(view(A, inds...), x)
1822+
_copy_or_fill!(A, inds, x::AbstractArray) = (A[inds...] = x)
1823+
18251824
"""
18261825
vcat(A...)
18271826

base/compiler/typelimits.jl

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ function _limit_type_size(@nospecialize(t), @nospecialize(c), sources::SimpleVec
135135
ct = Union{}
136136
end
137137
Qt = __limit_type_size(tt, ct, sources, depth + 1, 0)
138-
Qt === Any && return Type
139138
Qt === tt && return t
139+
Qt === Any && return Type
140140
# Can't form Type{<:Qt} just yet, without first make sure we limited the depth
141141
# enough, since this moves Qt outside of Type for is_derived_type_from_any
142142
Qt = __limit_type_size(tt, ct, sources, depth + 2, 0)
@@ -277,22 +277,9 @@ function type_more_complex(@nospecialize(t), @nospecialize(c), sources::SimpleVe
277277
else
278278
tupledepth = 0
279279
end
280-
isgenerator = (t.name.name === :Generator && t.name.module === _topmod(t.name.module))
281280
for i = 1:length(tP)
282281
tPi = tP[i]
283282
cPi = cP[i + ntail]
284-
if isgenerator
285-
let tPi = unwrap_unionall(tPi),
286-
cPi = unwrap_unionall(cPi)
287-
if isa(tPi, DataType) && isa(cPi, DataType) &&
288-
!isabstracttype(tPi) && !isabstracttype(cPi) &&
289-
sym_isless(cPi.name.name, tPi.name.name)
290-
# allow collect on (anonymous) Generators to nest, provided that their functions are appropriately ordered
291-
# TODO: is there a better way?
292-
continue
293-
end
294-
end
295-
end
296283
type_more_complex(tPi, cPi, sources, depth + 1, tupledepth, 0) && return true
297284
end
298285
return false

base/compiler/utilities.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ end
6666
is_meta_expr_head(head::Symbol) = head === :boundscheck || head === :meta || head === :loopinfo
6767
is_meta_expr(@nospecialize x) = isa(x, Expr) && is_meta_expr_head(x.head)
6868

69-
sym_isless(a::Symbol, b::Symbol) = ccall(:strcmp, Int32, (Ptr{UInt8}, Ptr{UInt8}), a, b) < 0
70-
7169
function is_self_quoting(@nospecialize(x))
7270
return isa(x,Number) || isa(x,AbstractString) || isa(x,Tuple) || isa(x,Type) ||
7371
isa(x,Char) || x === nothing || isa(x,Function)
@@ -390,6 +388,7 @@ function find_ssavalue_uses(body::Vector{Any}, nvals::Int)
390388
for line in 1:length(body)
391389
e = body[line]
392390
if isa(e, ReturnNode)
391+
isdefined(e, :val) || continue
393392
e = e.val
394393
elseif isa(e, GotoIfNot)
395394
e = e.cond

base/dict.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ end
176176
resize!(h.keys, newsz)
177177
resize!(h.vals, newsz)
178178
h.ndel = 0
179+
h.maxprobe = 0
179180
return h
180181
end
181182

@@ -251,6 +252,7 @@ function empty!(h::Dict{K,V}) where V where K
251252
resize!(h.vals, sz)
252253
h.ndel = 0
253254
h.count = 0
255+
h.maxprobe = 0
254256
h.age += 1
255257
h.idxfloor = sz
256258
return h

base/loading.jl

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ function _require(pkg::PkgId, env=nothing)
19541954
pkg_precompile_attempted = true
19551955
unlock(require_lock)
19561956
try
1957-
PKG_PRECOMPILE_HOOK[](pkg.name, _from_loading = true)
1957+
@invokelatest PKG_PRECOMPILE_HOOK[](pkg.name, _from_loading = true)
19581958
finally
19591959
lock(require_lock)
19601960
end
@@ -2398,12 +2398,6 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
23982398

23992399
# inherit permission from the source file (and make them writable)
24002400
chmod(tmppath, filemode(path) & 0o777 | 0o200)
2401-
if cache_objects
2402-
# Ensure that the user can execute the `.so` we're generating
2403-
# Note that on windows, `filemode(path)` typically returns `0o666`, so this
2404-
# addition of the execute bit for the user is doubly needed.
2405-
chmod(tmppath_so, filemode(path) & 0o777 | 0o333)
2406-
end
24072401

24082402
# prune the directory with cache files
24092403
if pkg.uuid !== nothing
@@ -2967,24 +2961,27 @@ global parse_pidfile_hook
29672961
# the same package cannot be precompiled from different projects and/or different preferences at the same time.
29682962
compilecache_pidfile_path(pkg::PkgId) = compilecache_path(pkg, UInt64(0); project="") * ".pidfile"
29692963

2964+
const compilecache_pidlock_stale_age = 10
2965+
29702966
# Allows processes to wait if another process is precompiling a given source already.
2971-
# The lock file mtime will be updated when held every `stale_age/2` seconds.
2967+
# The lock file mtime will be updated when held at most every `stale_age/2` seconds, with expected
2968+
# variance of 10 seconds or more being infrequent but not unusual.
29722969
# After `stale_age` seconds beyond the mtime of the lock file, the lock file is deleted and
2973-
# precompilation will proceed if
2974-
# - the locking process no longer exists
2975-
# - the lock is held by another host, since processes cannot be checked remotely
2976-
# or after `stale_age * 25` seconds if the process does still exist.
2977-
function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String; stale_age=10)
2970+
# precompilation will proceed if the locking process no longer exists or after `stale_age * 5`
2971+
# seconds if the process does still exist.
2972+
# If the lock is held by another host, it will conservatively wait `stale_age * 5`
2973+
# seconds since processes cannot be checked remotely
2974+
function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String; stale_age=compilecache_pidlock_stale_age)
29782975
if @isdefined(mkpidlock_hook) && @isdefined(trymkpidlock_hook) && @isdefined(parse_pidfile_hook)
29792976
pidfile = compilecache_pidfile_path(pkg)
29802977
cachefile = invokelatest(trymkpidlock_hook, f, pidfile; stale_age)
29812978
if cachefile === false
29822979
pid, hostname, age = invokelatest(parse_pidfile_hook, pidfile)
29832980
verbosity = isinteractive() ? CoreLogging.Info : CoreLogging.Debug
29842981
if isempty(hostname) || hostname == gethostname()
2985-
@logmsg verbosity "Waiting for another process (pid: $pid) to finish precompiling $pkg"
2982+
@logmsg verbosity "Waiting for another process (pid: $pid) to finish precompiling $pkg. Pidfile: $pidfile"
29862983
else
2987-
@logmsg verbosity "Waiting for another machine (hostname: $hostname, pid: $pid) to finish precompiling $pkg"
2984+
@logmsg verbosity "Waiting for another machine (hostname: $hostname, pid: $pid) to finish precompiling $pkg. Pidfile: $pidfile"
29882985
end
29892986
# wait until the lock is available, but don't actually acquire it
29902987
# returning nothing indicates a process waited for another

base/parse.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ function tryparse_internal(::Type{Complex{T}}, s::Union{String,SubString{String}
321321
if i₊ == i # leading ± sign
322322
i₊ = something(findnext(in(('+','-')), s, i₊+1), 0)
323323
end
324-
if i₊ != 0 && s[i₊-1] in ('e','E') # exponent sign
324+
if i₊ != 0 && s[prevind(s, i₊)] in ('e','E') # exponent sign
325325
i₊ = something(findnext(in(('+','-')), s, i₊+1), 0)
326326
end
327327

328328
# find trailing im/i/j
329329
iᵢ = something(findprev(in(('m','i','j')), s, e), 0)
330330
if iᵢ > 0 && s[iᵢ] == 'm' # im
331-
iᵢ -= 1
331+
iᵢ = prevind(s, iᵢ)
332332
if s[iᵢ] != 'i'
333333
raise && throw(ArgumentError("expected trailing \"im\", found only \"m\""))
334334
return nothing
@@ -337,7 +337,7 @@ function tryparse_internal(::Type{Complex{T}}, s::Union{String,SubString{String}
337337

338338
if i₊ == 0 # purely real or imaginary value
339339
if iᵢ > i && !(iᵢ == i+1 && s[i] in ('+','-')) # purely imaginary (not "±inf")
340-
x = tryparse_internal(T, s, i, iᵢ-1, raise)
340+
x = tryparse_internal(T, s, i, prevind(s, iᵢ), raise)
341341
x === nothing && return nothing
342342
return Complex{T}(zero(x),x)
343343
else # purely real
@@ -353,11 +353,11 @@ function tryparse_internal(::Type{Complex{T}}, s::Union{String,SubString{String}
353353
end
354354

355355
# parse real part
356-
re = tryparse_internal(T, s, i, i₊-1, raise)
356+
re = tryparse_internal(T, s, i, prevind(s, i₊), raise)
357357
re === nothing && return nothing
358358

359359
# parse imaginary part
360-
im = tryparse_internal(T, s, i₊+1, iᵢ-1, raise)
360+
im = tryparse_internal(T, s, i₊+1, prevind(s, iᵢ), raise)
361361
im === nothing && return nothing
362362

363363
return Complex{T}(re, s[i₊]=='-' ? -im : im)

base/range.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ function show(io::IO, r::LinRange{T}) where {T}
595595
print(io, "LinRange{")
596596
show(io, T)
597597
print(io, "}(")
598-
ioc = IOContext(io, :typeinto=>T)
598+
ioc = IOContext(io, :typeinfo=>T)
599599
show(ioc, first(r))
600600
print(io, ", ")
601601
show(ioc, last(r))

base/stacktraces.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ Base.@constprop :none function lookup(pointer::Ptr{Cvoid})
206206
elseif miroots !== nothing
207207
linfo = lookup_inline_frame_info(func, file, miroots)
208208
end
209-
linfo = linfo === nothing ? parentmodule(res[i + 1]) : linfo # e.g. `macro expansion`
210209
end
211210
res[i] = StackFrame(func, file, linenum, linfo, info[5]::Bool, info[6]::Bool, pointer)
212211
end

base/strings/util.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ function lstrip(f, s::AbstractString)
369369
end
370370
lstrip(s::AbstractString) = lstrip(isspace, s)
371371
lstrip(s::AbstractString, chars::Chars) = lstrip(in(chars), s)
372+
lstrip(::AbstractString, ::AbstractString) = throw(ArgumentError("Both arguments are strings. The second argument should be a `Char` or collection of `Char`s"))
372373

373374
"""
374375
rstrip([pred=isspace,] str::AbstractString) -> SubString
@@ -402,6 +403,8 @@ function rstrip(f, s::AbstractString)
402403
end
403404
rstrip(s::AbstractString) = rstrip(isspace, s)
404405
rstrip(s::AbstractString, chars::Chars) = rstrip(in(chars), s)
406+
rstrip(::AbstractString, ::AbstractString) = throw(ArgumentError("Both arguments are strings. The second argument should be a `Char` or collection of `Char`s"))
407+
405408

406409
"""
407410
strip([pred=isspace,] str::AbstractString) -> SubString
@@ -429,6 +432,7 @@ julia> strip("{3, 5}\\n", ['{', '}', '\\n'])
429432
"""
430433
strip(s::AbstractString) = lstrip(rstrip(s))
431434
strip(s::AbstractString, chars::Chars) = lstrip(rstrip(s, chars), chars)
435+
strip(::AbstractString, ::AbstractString) = throw(ArgumentError("Both arguments are strings. The second argument should be a `Char` or collection of `Char`s"))
432436
strip(f, s::AbstractString) = lstrip(f, rstrip(f, s))
433437

434438
## string padding functions ##
@@ -567,6 +571,8 @@ end
567571

568572
# Specialization for partition(s,n) to return a SubString
569573
eltype(::Type{PartitionIterator{T}}) where {T<:AbstractString} = SubString{T}
574+
# SubStrings do not nest
575+
eltype(::Type{PartitionIterator{T}}) where {T<:SubString} = T
570576

571577
function iterate(itr::PartitionIterator{<:AbstractString}, state = firstindex(itr.c))
572578
state > ncodeunits(itr.c) && return nothing

base/toml_parser.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ function _parse_key(l::Parser)
611611
else
612612
set_marker!(l)
613613
if accept_batch(l, isvalid_barekey_char)
614-
if !(peek(l) == '.' || peek(l) == ' ' || peek(l) == ']' || peek(l) == '=')
614+
if !(peek(l) == '.' || iswhitespace(peek(l)) || peek(l) == ']' || peek(l) == '=')
615615
c = eat_char(l)
616616
return ParserError(ErrInvalidBareKeyCharacter, c)
617617
end

0 commit comments

Comments
 (0)