Skip to content

Commit

Permalink
Backports release 1.10 (#51563)
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
KristofferC authored Nov 2, 2023
2 parents 45461be + 81d8c12 commit 1391444
Show file tree
Hide file tree
Showing 87 changed files with 1,392 additions and 1,234 deletions.
9 changes: 4 additions & 5 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1811,17 +1811,16 @@ function __cat_offset1!(A, shape, catdims, offsets, x)
inds = ntuple(length(offsets)) do i
(i <= length(catdims) && catdims[i]) ? offsets[i] .+ cat_indices(x, i) : 1:shape[i]
end
if x isa AbstractArray
A[inds...] = x
else
fill!(view(A, inds...), x)
end
_copy_or_fill!(A, inds, x)
newoffsets = ntuple(length(offsets)) do i
(i <= length(catdims) && catdims[i]) ? offsets[i] + cat_size(x, i) : offsets[i]
end
return newoffsets
end

_copy_or_fill!(A, inds, x) = fill!(view(A, inds...), x)
_copy_or_fill!(A, inds, x::AbstractArray) = (A[inds...] = x)

"""
vcat(A...)
Expand Down
15 changes: 1 addition & 14 deletions base/compiler/typelimits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ function _limit_type_size(@nospecialize(t), @nospecialize(c), sources::SimpleVec
ct = Union{}
end
Qt = __limit_type_size(tt, ct, sources, depth + 1, 0)
Qt === Any && return Type
Qt === tt && return t
Qt === Any && return Type
# Can't form Type{<:Qt} just yet, without first make sure we limited the depth
# enough, since this moves Qt outside of Type for is_derived_type_from_any
Qt = __limit_type_size(tt, ct, sources, depth + 2, 0)
Expand Down Expand Up @@ -277,22 +277,9 @@ function type_more_complex(@nospecialize(t), @nospecialize(c), sources::SimpleVe
else
tupledepth = 0
end
isgenerator = (t.name.name === :Generator && t.name.module === _topmod(t.name.module))
for i = 1:length(tP)
tPi = tP[i]
cPi = cP[i + ntail]
if isgenerator
let tPi = unwrap_unionall(tPi),
cPi = unwrap_unionall(cPi)
if isa(tPi, DataType) && isa(cPi, DataType) &&
!isabstracttype(tPi) && !isabstracttype(cPi) &&
sym_isless(cPi.name.name, tPi.name.name)
# allow collect on (anonymous) Generators to nest, provided that their functions are appropriately ordered
# TODO: is there a better way?
continue
end
end
end
type_more_complex(tPi, cPi, sources, depth + 1, tupledepth, 0) && return true
end
return false
Expand Down
3 changes: 1 addition & 2 deletions base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ end
is_meta_expr_head(head::Symbol) = head === :boundscheck || head === :meta || head === :loopinfo
is_meta_expr(@nospecialize x) = isa(x, Expr) && is_meta_expr_head(x.head)

sym_isless(a::Symbol, b::Symbol) = ccall(:strcmp, Int32, (Ptr{UInt8}, Ptr{UInt8}), a, b) < 0

function is_self_quoting(@nospecialize(x))
return isa(x,Number) || isa(x,AbstractString) || isa(x,Tuple) || isa(x,Type) ||
isa(x,Char) || x === nothing || isa(x,Function)
Expand Down Expand Up @@ -390,6 +388,7 @@ function find_ssavalue_uses(body::Vector{Any}, nvals::Int)
for line in 1:length(body)
e = body[line]
if isa(e, ReturnNode)
isdefined(e, :val) || continue
e = e.val
elseif isa(e, GotoIfNot)
e = e.cond
Expand Down
2 changes: 2 additions & 0 deletions base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ end
resize!(h.keys, newsz)
resize!(h.vals, newsz)
h.ndel = 0
h.maxprobe = 0
return h
end

Expand Down Expand Up @@ -251,6 +252,7 @@ function empty!(h::Dict{K,V}) where V where K
resize!(h.vals, sz)
h.ndel = 0
h.count = 0
h.maxprobe = 0
h.age += 1
h.idxfloor = sz
return h
Expand Down
27 changes: 12 additions & 15 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ function _require(pkg::PkgId, env=nothing)
pkg_precompile_attempted = true
unlock(require_lock)
try
PKG_PRECOMPILE_HOOK[](pkg.name, _from_loading = true)
@invokelatest PKG_PRECOMPILE_HOOK[](pkg.name, _from_loading = true)
finally
lock(require_lock)
end
Expand Down Expand Up @@ -2398,12 +2398,6 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in

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

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

const compilecache_pidlock_stale_age = 10

# Allows processes to wait if another process is precompiling a given source already.
# The lock file mtime will be updated when held every `stale_age/2` seconds.
# The lock file mtime will be updated when held at most every `stale_age/2` seconds, with expected
# variance of 10 seconds or more being infrequent but not unusual.
# After `stale_age` seconds beyond the mtime of the lock file, the lock file is deleted and
# precompilation will proceed if
# - the locking process no longer exists
# - the lock is held by another host, since processes cannot be checked remotely
# or after `stale_age * 25` seconds if the process does still exist.
function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String; stale_age=10)
# precompilation will proceed if the locking process no longer exists or after `stale_age * 5`
# seconds if the process does still exist.
# If the lock is held by another host, it will conservatively wait `stale_age * 5`
# seconds since processes cannot be checked remotely
function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String; stale_age=compilecache_pidlock_stale_age)
if @isdefined(mkpidlock_hook) && @isdefined(trymkpidlock_hook) && @isdefined(parse_pidfile_hook)
pidfile = compilecache_pidfile_path(pkg)
cachefile = invokelatest(trymkpidlock_hook, f, pidfile; stale_age)
if cachefile === false
pid, hostname, age = invokelatest(parse_pidfile_hook, pidfile)
verbosity = isinteractive() ? CoreLogging.Info : CoreLogging.Debug
if isempty(hostname) || hostname == gethostname()
@logmsg verbosity "Waiting for another process (pid: $pid) to finish precompiling $pkg"
@logmsg verbosity "Waiting for another process (pid: $pid) to finish precompiling $pkg. Pidfile: $pidfile"
else
@logmsg verbosity "Waiting for another machine (hostname: $hostname, pid: $pid) to finish precompiling $pkg"
@logmsg verbosity "Waiting for another machine (hostname: $hostname, pid: $pid) to finish precompiling $pkg. Pidfile: $pidfile"
end
# wait until the lock is available, but don't actually acquire it
# returning nothing indicates a process waited for another
Expand Down
10 changes: 5 additions & 5 deletions base/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ function tryparse_internal(::Type{Complex{T}}, s::Union{String,SubString{String}
if i₊ == i # leading ± sign
i₊ = something(findnext(in(('+','-')), s, i₊+1), 0)
end
if i₊ != 0 && s[i₊-1] in ('e','E') # exponent sign
if i₊ != 0 && s[prevind(s, i₊)] in ('e','E') # exponent sign
i₊ = something(findnext(in(('+','-')), s, i₊+1), 0)
end

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

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

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

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

return Complex{T}(re, s[i₊]=='-' ? -im : im)
Expand Down
2 changes: 1 addition & 1 deletion base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ function show(io::IO, r::LinRange{T}) where {T}
print(io, "LinRange{")
show(io, T)
print(io, "}(")
ioc = IOContext(io, :typeinto=>T)
ioc = IOContext(io, :typeinfo=>T)
show(ioc, first(r))
print(io, ", ")
show(ioc, last(r))
Expand Down
1 change: 0 additions & 1 deletion base/stacktraces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ Base.@constprop :none function lookup(pointer::Ptr{Cvoid})
elseif miroots !== nothing
linfo = lookup_inline_frame_info(func, file, miroots)
end
linfo = linfo === nothing ? parentmodule(res[i + 1]) : linfo # e.g. `macro expansion`
end
res[i] = StackFrame(func, file, linenum, linfo, info[5]::Bool, info[6]::Bool, pointer)
end
Expand Down
6 changes: 6 additions & 0 deletions base/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ function lstrip(f, s::AbstractString)
end
lstrip(s::AbstractString) = lstrip(isspace, s)
lstrip(s::AbstractString, chars::Chars) = lstrip(in(chars), s)
lstrip(::AbstractString, ::AbstractString) = throw(ArgumentError("Both arguments are strings. The second argument should be a `Char` or collection of `Char`s"))

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


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

## string padding functions ##
Expand Down Expand Up @@ -567,6 +571,8 @@ end

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

function iterate(itr::PartitionIterator{<:AbstractString}, state = firstindex(itr.c))
state > ncodeunits(itr.c) && return nothing
Expand Down
2 changes: 1 addition & 1 deletion base/toml_parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ function _parse_key(l::Parser)
else
set_marker!(l)
if accept_batch(l, isvalid_barekey_char)
if !(peek(l) == '.' || peek(l) == ' ' || peek(l) == ']' || peek(l) == '=')
if !(peek(l) == '.' || iswhitespace(peek(l)) || peek(l) == ']' || peek(l) == '=')
c = eat_char(l)
return ParserError(ErrInvalidBareKeyCharacter, c)
end
Expand Down
5 changes: 3 additions & 2 deletions base/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -606,14 +606,15 @@ any(x::Tuple{Bool, Bool}) = x[1]|x[2]
any(x::Tuple{Bool, Bool, Bool}) = x[1]|x[2]|x[3]

# a version of `in` esp. for NamedTuple, to make it pure, and not compiled for each tuple length
function sym_in(x::Symbol, @nospecialize itr::Tuple{Vararg{Symbol}})
function sym_in(x::Symbol, itr::Tuple{Vararg{Symbol}})
@noinline
@_total_meta
for y in itr
y === x && return true
end
return false
end
in(x::Symbol, @nospecialize itr::Tuple{Vararg{Symbol}}) = sym_in(x, itr)
in(x::Symbol, itr::Tuple{Vararg{Symbol}}) = sym_in(x, itr)


"""
Expand Down
4 changes: 3 additions & 1 deletion contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const fancyprint = (stdout isa Base.TTY) && Base.get_bool_env("CI", false) !== t
##

CTRL_C = '\x03'
CTRL_D = '\x04'
CTRL_R = '\x12'
UP_ARROW = "\e[A"
DOWN_ARROW = "\e[B"
Expand All @@ -44,6 +45,7 @@ precompile(Tuple{typeof(delete!), Dict{Base.PkgId,Vector{Function}}, Base.PkgId}
precompile(Tuple{typeof(push!), Vector{Function}, Function})
# miscellaneous
precompile(Tuple{typeof(Base.exit)})
precompile(Tuple{typeof(Base.require), Base.PkgId})
precompile(Tuple{typeof(Base.recursive_prefs_merge), Base.Dict{String, Any}})
precompile(Tuple{typeof(Base.recursive_prefs_merge), Base.Dict{String, Any}, Base.Dict{String, Any}, Vararg{Base.Dict{String, Any}}})
Expand Down Expand Up @@ -373,7 +375,7 @@ generate_precompile_statements() = try # Make sure `ansi_enablecursor` is printe
end
end
end
write(ptm, "exit()\n")
write(ptm, "$CTRL_D")
wait(tee)
success(p) || Base.pipeline_error(p)
close(ptm)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a68258944ba3c7b8a31864ad5dc6e320
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e7ea74323f873e6ff0b92b19d368a16df768f21474222ef38918d36d827c92a5597e7fa243e9ef985b02f3bcf65d41904cfeeae9aca64612fdfbb9483c3cbd12

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85c5dcb49f11bce2d6bb75ef620ea892
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a1810991895650263c33c3e9c2b3089c66948b86b4de16c4c06ed49841cf5500814641576a6b735d5cf3841991684e908c4828a56ee218be216424e6aa9d5f43
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
46541001073d1c3c85e18d910f8308f3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f7470a447b934ca9315e216a07b97e363f11bc93186f9aa057b20b2d05092c58ae4f1b733de362de4a0730861c00be4ca5588d0b3ba65f018c1798b9122b9672
Loading

0 comments on commit 1391444

Please sign in to comment.