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 for 1.10.0-rc2 #52045

Merged
merged 38 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ba2a8a3
Use a simple error when reporting sysimg load failures. (#51598)
maleadt Oct 5, 2023
1aa5055
fix parallel peakflop usage (#51757)
KristofferC Oct 20, 2023
feb75f8
allow finalizers to take any locks and yield during exit (#51848)
vtjnash Oct 25, 2023
db55742
add missing wait during Timer and AsyncCondition close (#51847)
vtjnash Oct 25, 2023
35264b7
Add aliasing warnings to docstrings for mutating functions in Base (#…
gdalle Oct 27, 2023
3a4b140
further fix to the new promoting method for AbstractDateTime subtract…
JeffBezanson Nov 1, 2023
2d6af7e
macroexpand: handle const/atomic struct fields correctly (#51980)
Pangoraw Nov 2, 2023
3b6e9dd
[Artifacts] Pass artifacts dictionary to `ensure_artifact_installed` …
ashutosh-b-b Nov 2, 2023
6f864a7
Bump Statistics (#52030)
nalimilan Nov 9, 2023
405e1a4
Wait for other threads to finish compiling before exiting (#51213)
gbaraldi Sep 6, 2023
f5adece
[devdocs] Improve documentation about building external forks of LLVM…
giordano Nov 1, 2023
3ffa3db
fix sorting for iterables that define copymutable (#52086)
vtjnash Nov 9, 2023
8b85bbf
Fix errors in `sort` docstring (#52098)
LilithHafner Nov 10, 2023
1ddd6da
Bump JuliaSyntax to 0.4.7 (#52136)
c42f Nov 13, 2023
99c4ae4
Make allocopt respect the GC verifier rules with non usual address sp…
gbaraldi Sep 30, 2023
0a1e83e
Make c func `abspath` consistent on Windows. Fix tracking path conver…
IanButterworth Nov 15, 2023
dc2c4f1
[REPL] fix computation of startpos for path completions (#52009)
IanButterworth Nov 15, 2023
0218599
cap the number of GC threads to number of cpu cores (#52192)
d-netto Nov 17, 2023
f67439c
Make have_fma consistent between interpreter and compiled (#52206)
gbaraldi Nov 21, 2023
e9acaf5
fix Unicode.julia_chartransform for Julia 1.10 (#52027)
stevengj Nov 22, 2023
99d71c0
More helpful error message for empty `cpu_target` in `Base.julia_cmd`…
giordano Nov 27, 2023
2638522
Memoize `cwstring` when used for env lookup / modification on Windows…
MasonProtter Nov 27, 2023
9c097b6
Revert "Support sorting iterators (#46104)" (#52010)
KristofferC Nov 17, 2023
2030e7d
Turn Method Overwritten Error into a PrecompileError -- turning off c…
vchuravy Nov 24, 2023
9f55128
Devdocs on fixing precompile hangs, take 2 (#51895)
JeffBezanson Nov 13, 2023
5c9602e
Don't mark nonlocal symbols as hidden (#51596)
vchuravy Oct 7, 2023
4aeef21
[REPLCompletions] allow symbol completions within incomplete macrocal…
aviatesk Oct 25, 2023
4f7feb1
add support for async backtraces of Tasks on any thread (#51430)
vtjnash Sep 25, 2023
a16e4e1
Fix segfault if root task is NULL (#51471)
kpamnany Sep 27, 2023
e8673bd
codegen: ensure i1 bool is widened to i8 before storing (#52189)
vtjnash Nov 17, 2023
db56488
refactor GC scanning code to reflect jl_binding_t are now first class…
d-netto Aug 26, 2023
e77afbf
Fix multiversioning issues caused by the parallel llvm work (#52194)
gbaraldi Nov 24, 2023
1e3842c
bump SparseArrays to latest v1.10
KristofferC Nov 27, 2023
46617e5
bump Pkg to latest v1.10
KristofferC Nov 27, 2023
0e96c9c
Fix getfield codegen for tuple inputs and unknown symbol fields. (#51…
maleadt Sep 7, 2023
332d9f3
jitlayers: replace sharedbytes intern pool with one that respects ali…
vtjnash Nov 17, 2023
465ff74
jitlayers: reduce excess alignment of #52182 (#52210)
vtjnash Nov 20, 2023
b497f44
simplify call to promote_eltype with repeated elements (#51135)
vtjnash Sep 1, 2023
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
4 changes: 4 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ USE_MLIR := 0
# Options to use RegionVectorizer
USE_RV := 0

# Use `ccache` for speeding up recompilation of the C/C++ part of Julia.
# Requires the `ccache` executable to be in the `PATH` environment variable.
USECCACHE := 0

# Cross-compile
#XC_HOST := i686-w64-mingw32
#XC_HOST := x86_64-w64-mingw32
Expand Down
6 changes: 6 additions & 0 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ time_ns() = ccall(:jl_hrtime, UInt64, ())

start_base_include = time_ns()

# A warning to be interpolated in the docstring of every dangerous mutating function in Base, see PR #50824
const _DOCS_ALIASING_WARNING = """
!!! warning
Behavior can be unexpected when any mutated argument shares memory with any other argument.
"""

## Load essential files and libraries
include("essentials.jl")
include("ctypes.jl")
Expand Down
10 changes: 10 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,8 @@ If `dst` and `src` are of the same type, `dst == src` should hold after
the call. If `dst` and `src` are multidimensional arrays, they must have
equal [`axes`](@ref).

$(_DOCS_ALIASING_WARNING)

See also [`copyto!`](@ref).

!!! compat "Julia 1.1"
Expand Down Expand Up @@ -1369,6 +1371,8 @@ _unsafe_ind2sub(sz, i) = (@inline; _ind2sub(sz, i))
Store values from array `X` within some subset of `A` as specified by `inds`.
The syntax `A[inds...] = X` is equivalent to `(setindex!(A, X, inds...); X)`.

$(_DOCS_ALIASING_WARNING)

# Examples
```jldoctest
julia> A = zeros(2,2);
Expand Down Expand Up @@ -1587,10 +1591,14 @@ eltypeof(x::AbstractArray) = eltype(x)
promote_eltypeof() = error()
promote_eltypeof(v1) = eltypeof(v1)
promote_eltypeof(v1, vs...) = promote_type(eltypeof(v1), promote_eltypeof(vs...))
promote_eltypeof(v1::T, vs::T...) where {T} = eltypeof(v1)
promote_eltypeof(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T

promote_eltype() = error()
promote_eltype(v1) = eltype(v1)
promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...))
promote_eltype(v1::T, vs::T...) where {T} = eltype(T)
promote_eltype(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T

#TODO: ERROR CHECK
_cat(catdim::Int) = Vector{Any}()
Expand Down Expand Up @@ -3339,6 +3347,8 @@ end
Like [`map`](@ref), but stores the result in `destination` rather than a new
collection. `destination` must be at least as large as the smallest collection.

$(_DOCS_ALIASING_WARNING)

See also: [`map`](@ref), [`foreach`](@ref), [`zip`](@ref), [`copyto!`](@ref).

# Examples
Expand Down
8 changes: 8 additions & 0 deletions base/abstractset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const ∪ = union
Construct the [`union`](@ref) of passed in sets and overwrite `s` with the result.
Maintain order with arrays.

$(_DOCS_ALIASING_WARNING)

# Examples
```jldoctest
julia> a = Set([3, 4, 5]);
Expand Down Expand Up @@ -182,6 +184,8 @@ const ∩ = intersect

Intersect all passed in sets and overwrite `s` with the result.
Maintain order with arrays.

$(_DOCS_ALIASING_WARNING)
"""
function intersect!(s::AbstractSet, itrs...)
for x in itrs
Expand Down Expand Up @@ -218,6 +222,8 @@ setdiff(s) = union(s)
Remove from set `s` (in-place) each element of each iterable from `itrs`.
Maintain order with arrays.

$(_DOCS_ALIASING_WARNING)

# Examples
```jldoctest
julia> a = Set([1, 3, 4, 5]);
Expand Down Expand Up @@ -272,6 +278,8 @@ symdiff(s) = symdiff!(copy(s))
Construct the symmetric difference of the passed in sets, and overwrite `s` with the result.
When `s` is an array, the order is maintained.
Note that in this case the multiplicity of elements matters.

$(_DOCS_ALIASING_WARNING)
"""
function symdiff!(s::AbstractSet, itrs...)
for x in itrs
Expand Down
8 changes: 8 additions & 0 deletions base/accumulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ end
cumsum!(B, A; dims::Integer)

Cumulative sum of `A` along the dimension `dims`, storing the result in `B`. See also [`cumsum`](@ref).

$(_DOCS_ALIASING_WARNING)
"""
cumsum!(B::AbstractArray{T}, A; dims::Integer) where {T} =
accumulate!(add_sum, B, A, dims=dims)
Expand Down Expand Up @@ -150,6 +152,8 @@ cumsum(itr) = accumulate(add_sum, itr)

Cumulative product of `A` along the dimension `dims`, storing the result in `B`.
See also [`cumprod`](@ref).

$(_DOCS_ALIASING_WARNING)
"""
cumprod!(B::AbstractArray{T}, A; dims::Integer) where {T} =
accumulate!(mul_prod, B, A, dims=dims)
Expand All @@ -159,6 +163,8 @@ cumprod!(B::AbstractArray{T}, A; dims::Integer) where {T} =

Cumulative product of a vector `x`, storing the result in `y`.
See also [`cumprod`](@ref).

$(_DOCS_ALIASING_WARNING)
"""
cumprod!(y::AbstractVector, x::AbstractVector) = cumprod!(y, x, dims=1)

Expand Down Expand Up @@ -301,6 +307,8 @@ Cumulative operation `op` on `A` along the dimension `dims`, storing the result
Providing `dims` is optional for vectors. If the keyword argument `init` is given, its
value is used to instantiate the accumulation.

$(_DOCS_ALIASING_WARNING)

See also [`accumulate`](@ref), [`cumsum!`](@ref), [`cumprod!`](@ref).

# Examples
Expand Down
6 changes: 6 additions & 0 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ source and `do` in the destination (1-indexed).
The `unsafe` prefix on this function indicates that no validation is performed to ensure
that N is inbounds on either array. Incorrect usage may corrupt or segfault your program, in
the same manner as C.

$(_DOCS_ALIASING_WARNING)
"""
function unsafe_copyto!(dest::Array{T}, doffs, src::Array{T}, soffs, n) where T
t1 = @_gc_preserve_begin dest
Expand Down Expand Up @@ -1781,6 +1783,8 @@ place of the removed items; in this case, `indices` must be a `AbstractUnitRange
To insert `replacement` before an index `n` without removing any items, use
`splice!(collection, n:n-1, replacement)`.

$(_DOCS_ALIASING_WARNING)

!!! compat "Julia 1.5"
Prior to Julia 1.5, `indices` must always be a `UnitRange`.

Expand Down Expand Up @@ -2760,6 +2764,8 @@ Remove the items at all the indices which are not given by `inds`,
and return the modified `a`.
Items which are kept are shifted to fill the resulting gaps.

$(_DOCS_ALIASING_WARNING)

`inds` must be an iterator of sorted and unique integer indices.
See also [`deleteat!`](@ref).

Expand Down
39 changes: 32 additions & 7 deletions base/asyncevent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,26 @@ end
unsafe_convert(::Type{Ptr{Cvoid}}, t::Timer) = t.handle
unsafe_convert(::Type{Ptr{Cvoid}}, async::AsyncCondition) = async.handle

# if this returns true, the object has been signaled
# if this returns false, the object is closed
function _trywait(t::Union{Timer, AsyncCondition})
set = t.set
if set
# full barrier now for AsyncCondition
t isa Timer || Core.Intrinsics.atomic_fence(:acquire_release)
else
t.isopen || return false
t.handle == C_NULL && return false
if !isopen(t)
close(t) # wait for the close to complete
return false
end
iolock_begin()
set = t.set
if !set
preserve_handle(t)
lock(t.cond)
try
set = t.set
if !set && t.isopen && t.handle != C_NULL
if !set && t.handle != C_NULL # wait for set or handle, but not the isopen flag
iolock_end()
set = wait(t.cond)
unlock(t.cond)
Expand All @@ -160,10 +164,28 @@ end
isopen(t::Union{Timer, AsyncCondition}) = t.isopen && t.handle != C_NULL

function close(t::Union{Timer, AsyncCondition})
t.handle == C_NULL && return # short-circuit path
iolock_begin()
if isopen(t)
@atomic :monotonic t.isopen = false
ccall(:jl_close_uv, Cvoid, (Ptr{Cvoid},), t)
if t.handle != C_NULL
if t.isopen
@atomic :monotonic t.isopen = false
ccall(:jl_close_uv, Cvoid, (Ptr{Cvoid},), t)
end
# implement _trywait here without the auto-reset function, just waiting for the final close signal
preserve_handle(t)
lock(t.cond)
try
while t.handle != C_NULL
iolock_end()
wait(t.cond)
unlock(t.cond)
iolock_begin()
lock(t.cond)
end
finally
unlock(t.cond)
unpreserve_handle(t)
end
end
iolock_end()
nothing
Expand Down Expand Up @@ -220,7 +242,10 @@ function uv_timercb(handle::Ptr{Cvoid})
@atomic :monotonic t.set = true
if ccall(:uv_timer_get_repeat, UInt64, (Ptr{Cvoid},), t) == 0
# timer is stopped now
close(t)
if t.isopen
@atomic :monotonic t.isopen = false
ccall(:jl_close_uv, Cvoid, (Ptr{Cvoid},), t)
end
end
notify(t.cond, true)
finally
Expand Down
2 changes: 2 additions & 0 deletions base/asyncmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ length(itr::AsyncGenerator) = length(itr.collector.enumerator)

Like [`asyncmap`](@ref), but stores output in `results` rather than
returning a collection.

$(_DOCS_ALIASING_WARNING)
"""
function asyncmap!(f, r, c1, c...; ntasks=0, batch_size=nothing)
foreach(identity, AsyncCollector(f, r, c1, c...; ntasks=ntasks, batch_size=batch_size))
Expand Down
2 changes: 2 additions & 0 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ struct InitError <: WrappedException
error
end

struct PrecompilableError <: Exception end

String(s::String) = s # no constructor yet

const Cvoid = Nothing
Expand Down
4 changes: 4 additions & 0 deletions base/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ it is even faster to write into a pre-allocated output array with `u .= @view v[
(Even though `permute!` overwrites `v` in-place, it internally requires some allocation
to keep track of which elements have been moved.)

$(_DOCS_ALIASING_WARNING)

See also [`invpermute!`](@ref).

# Examples
Expand Down Expand Up @@ -222,6 +224,8 @@ Note that if you have a pre-allocated output array (e.g. `u = similar(v)`),
it is quicker to instead employ `u[p] = v`. (`invpermute!` internally
allocates a copy of the data.)

$(_DOCS_ALIASING_WARNING)

# Examples
```jldoctest
julia> A = [1, 1, 3, 4];
Expand Down
25 changes: 21 additions & 4 deletions base/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@
if Sys.iswindows()
const ERROR_ENVVAR_NOT_FOUND = UInt32(203)

const env_dict = IdDict{String, Vector{Cwchar_t}}()
const env_lock = ReentrantLock()

function memoized_env_lookup(str::AbstractString)
# Windows environment variables have a different format from Linux / MacOS, and previously
# incurred allocations because we had to convert a String to a Vector{Cwchar_t} each time
# an environment variable was looked up. This function memoizes that lookup process, storing
# the String => Vector{Cwchar_t} pairs in env_dict
var = get(env_dict, str, nothing)
if isnothing(var)
var = @lock env_lock begin
env_dict[str] = cwstring(str)
end
end
var
end

_getenvlen(var::Vector{UInt16}) = ccall(:GetEnvironmentVariableW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32),var,C_NULL,0)
_hasenv(s::Vector{UInt16}) = _getenvlen(s) != 0 || Libc.GetLastError() != ERROR_ENVVAR_NOT_FOUND
_hasenv(s::AbstractString) = _hasenv(cwstring(s))
_hasenv(s::AbstractString) = _hasenv(memoized_env_lookup(s))

function access_env(onError::Function, str::AbstractString)
var = cwstring(str)
var = memoized_env_lookup(str)
len = _getenvlen(var)
if len == 0
return Libc.GetLastError() != ERROR_ENVVAR_NOT_FOUND ? "" : onError(str)
Expand All @@ -21,7 +38,7 @@ if Sys.iswindows()
end

function _setenv(svar::AbstractString, sval::AbstractString, overwrite::Bool=true)
var = cwstring(svar)
var = memoized_env_lookup(svar)
val = cwstring(sval)
if overwrite || !_hasenv(var)
ret = ccall(:SetEnvironmentVariableW,stdcall,Int32,(Ptr{UInt16},Ptr{UInt16}),var,val)
Expand All @@ -30,7 +47,7 @@ if Sys.iswindows()
end

function _unsetenv(svar::AbstractString)
var = cwstring(svar)
var = memoized_env_lookup(svar)
ret = ccall(:SetEnvironmentVariableW,stdcall,Int32,(Ptr{UInt16},Ptr{UInt16}),var,C_NULL)
windowserror(:setenv, ret == 0 && Libc.GetLastError() != ERROR_ENVVAR_NOT_FOUND)
end
Expand Down
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ function include_dependency(path::AbstractString)
end

# we throw PrecompilableError when a module doesn't want to be precompiled
struct PrecompilableError <: Exception end
import Core: PrecompilableError
function show(io::IO, ex::PrecompilableError)
print(io, "Declaring __precompile__(false) is not allowed in files that are being precompiled.")
end
Expand Down
5 changes: 3 additions & 2 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1179,8 +1179,7 @@ circshift!(dest::AbstractArray, src, ::Tuple{}) = copyto!(dest, src)
Circularly shift, i.e. rotate, the data in `src`, storing the result in
`dest`. `shifts` specifies the amount to shift in each dimension.

The `dest` array must be distinct from the `src` array (they cannot
alias each other).
$(_DOCS_ALIASING_WARNING)

See also [`circshift`](@ref).
"""
Expand Down Expand Up @@ -1238,6 +1237,8 @@ their indices; any offset results in a (circular) wraparound. If the
arrays have overlapping indices, then on the domain of the overlap
`dest` agrees with `src`.

$(_DOCS_ALIASING_WARNING)

See also: [`circshift`](@ref).

# Examples
Expand Down
Loading