Skip to content

Commit a773c8b

Browse files
authored
release-1.9: Backports for 1.9.3 (#50507)
Backported PRs: - [x] #47782 <!-- Generalize Bool parse method to AbstractString --> - [x] #48634 <!-- Remove unused "deps" mechanism in internal sorting keywords [NFC] --> - [x] #49931 <!-- Lock finalizers' lists at exit --> - [x] #50064 <!-- Fix numbered prompt with input only with comment --> - [x] #50474 <!-- docs: Fix a `!!! note` which was miscapitalized --> - [x] #50516 <!-- Fix visibility of assert on GCC12/13 --> - [x] #50635 <!-- `versioninfo()`: include build info and unofficial warning --> - [x] #49915 <!-- Revert "Remove number / vector (#44358)" --> - [x] #50781 <!-- fix `bit_map!` with aliasing --> - [x] #50845 <!-- fix #50438, use default pool for at-threads --> - [x] #49031 <!-- Update inference.md --> - [x] #50289 <!-- Initialize prev_nold and nold in gc_reset_page --> - [x] #50559 <!-- Expand kwcall lowering positional default check to vararg --> - [x] #49582 <!-- Update HISTORY.md for `DelimitedFiles` --> - [x] #50341 <!-- invokelatest docs should say not exported before 1.9 --> - [x] #50525 <!-- only check that values are finite in `generic_lufact` when `check=true` --> - [x] #50444 <!-- Optimize getfield lowering to avoid boxing in some cases --> - [x] #50523 <!-- Avoid generic call in most cases for getproperty --> - [x] #50860 <!-- Add `Base.get_extension` to docs/API --> - [x] #50164 <!-- codegen: handle dead code with unsafe_store of FCA pointers --> - [x] #50568 <!-- `Array(::AbstractRange)` should return an `Array` --> - [x] #50871 <!-- macOS: Don't inspect dead threadtls during exception handling. --> Need manual backport: - [ ] #48542 <!-- Add docs on task-specific buffering using multithreading --> - [ ] #50591 <!-- build: fix various makefile bugs --> Non-merged PRs with backport label: - [ ] #50842 <!-- Avoid race conditions with recursive rm --> - [ ] #50823 <!-- Make ranges more robust with unsigned indexes. --> - [ ] #50663 <!-- Fix Expr(:loopinfo) codegen --> - [ ] #49716 <!-- Update varinfo() docstring signature --> - [ ] #49713 <!-- prevent REPL from erroring in numbered mode in some situations --> - [ ] #49573 <!-- Implement jl_cpu_pause on PPC64 --> - [ ] #48726 <!-- fix macro expansion of property destructuring --> - [ ] #48642 <!-- Use gc alloc instead of alloc typed in lowering --> - [ ] #48183 <!-- Don't use pkgimage for package if any includes fall in tracked path for coverage or alloc tracking --> - [ ] #48050 <!-- improve `--heap-size-hint` arg handling --> - [ ] #47615 <!-- Allow threadsafe access to buffer of type inference profiling trees -->
2 parents 6fc1be0 + c25c2bc commit a773c8b

33 files changed

+243
-33
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ Standard library changes
181181

182182
#### DelimitedFiles
183183

184-
* DelimitedFiles has been moved out as a separate package. It now has to be explicitly installed to be used.
184+
* DelimitedFiles has been moved out as a separate package.
185185

186186
Deprecated or removed
187187
---------------------

base/abstractarray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ false
766766
checkindex(::Type{Bool}, inds::AbstractUnitRange, i) =
767767
throw(ArgumentError("unable to check bounds for indices of type $(typeof(i))"))
768768
checkindex(::Type{Bool}, inds::AbstractUnitRange, i::Real) = (first(inds) <= i) & (i <= last(inds))
769+
checkindex(::Type{Bool}, inds::IdentityUnitRange, i::Real) = checkindex(Bool, inds.indices, i)
770+
checkindex(::Type{Bool}, inds::OneTo{T}, i::T) where {T<:BitInteger} = unsigned(i - one(i)) < unsigned(last(inds))
769771
checkindex(::Type{Bool}, inds::AbstractUnitRange, ::Colon) = true
770772
checkindex(::Type{Bool}, inds::AbstractUnitRange, ::Slice) = true
771773
function checkindex(::Type{Bool}, inds::AbstractUnitRange, r::AbstractRange)

base/bitarray.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,9 +1791,10 @@ function bit_map!(f::F, dest::BitArray, A::BitArray) where F
17911791
dest_last = destc[len_Ac]
17921792
_msk = _msk_end(A)
17931793
# first zero out the bits mask is going to change
1794-
destc[len_Ac] = (dest_last & (~_msk))
17951794
# then update bits by `or`ing with a masked RHS
1796-
destc[len_Ac] |= f(Ac[len_Ac]) & _msk
1795+
# DO NOT SEPARATE ONTO TO LINES.
1796+
# Otherwise there will be bugs when Ac aliases destc
1797+
destc[len_Ac] = (dest_last & (~_msk)) | f(Ac[len_Ac]) & _msk
17971798
dest
17981799
end
17991800
function bit_map!(f::F, dest::BitArray, A::BitArray, B::BitArray) where F
@@ -1812,9 +1813,10 @@ function bit_map!(f::F, dest::BitArray, A::BitArray, B::BitArray) where F
18121813
dest_last = destc[len_Ac]
18131814
_msk = _msk_end(min_bitlen)
18141815
# first zero out the bits mask is going to change
1815-
destc[len_Ac] = (dest_last & ~(_msk))
18161816
# then update bits by `or`ing with a masked RHS
1817-
destc[len_Ac] |= f(Ac[end], Bc[end]) & _msk
1817+
# DO NOT SEPARATE ONTO TO LINES.
1818+
# Otherwise there will be bugs when Ac or Bc aliases destc
1819+
destc[len_Ac] = (dest_last & ~(_msk)) | f(Ac[end], Bc[end]) & _msk
18181820
dest
18191821
end
18201822

base/essentials.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,9 @@ e.g. long-running event loops or callback functions that may
809809
call obsolete versions of a function `f`.
810810
(The drawback is that `invokelatest` is somewhat slower than calling
811811
`f` directly, and the type of the result cannot be inferred by the compiler.)
812+
813+
!!! compat "Julia 1.9"
814+
Prior to Julia 1.9, this function was not exported, and was called as `Base.invokelatest`.
812815
"""
813816
function invokelatest(@nospecialize(f), @nospecialize args...; kwargs...)
814817
kwargs = merge(NamedTuple(), kwargs)

base/parse.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function tryparse_internal(::Type{T}, s::AbstractString, startpos::Int, endpos::
176176
return n
177177
end
178178

179-
function tryparse_internal(::Type{Bool}, sbuff::Union{String,SubString{String}},
179+
function tryparse_internal(::Type{Bool}, sbuff::AbstractString,
180180
startpos::Int, endpos::Int, base::Integer, raise::Bool)
181181
if isempty(sbuff)
182182
raise && throw(ArgumentError("input string is empty"))
@@ -202,10 +202,15 @@ function tryparse_internal(::Type{Bool}, sbuff::Union{String,SubString{String}},
202202
end
203203

204204
len = endpos - startpos + 1
205-
p = pointer(sbuff) + startpos - 1
206-
GC.@preserve sbuff begin
207-
(len == 4) && (0 == _memcmp(p, "true", 4)) && (return true)
208-
(len == 5) && (0 == _memcmp(p, "false", 5)) && (return false)
205+
if sbuff isa Union{String, SubString{String}}
206+
p = pointer(sbuff) + startpos - 1
207+
GC.@preserve sbuff begin
208+
(len == 4) && (0 == _memcmp(p, "true", 4)) && (return true)
209+
(len == 5) && (0 == _memcmp(p, "false", 5)) && (return false)
210+
end
211+
else
212+
(len == 4) && (SubString(sbuff, startpos:startpos+3) == "true") && (return true)
213+
(len == 5) && (SubString(sbuff, startpos:startpos+4) == "false") && (return false)
209214
end
210215

211216
if raise

base/range.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,8 +1363,21 @@ function vcat(rs::AbstractRange{T}...) where T
13631363
return a
13641364
end
13651365

1366-
Array{T,1}(r::AbstractRange{T}) where {T} = vcat(r)
1367-
collect(r::AbstractRange) = vcat(r)
1366+
# This method differs from that for AbstractArrays as it
1367+
# use iteration instead of indexing. This works even if certain
1368+
# non-standard ranges don't support indexing.
1369+
# See https://github.com/JuliaLang/julia/pull/27302
1370+
# Similarly, collect(r::AbstractRange) uses iteration
1371+
function Array{T,1}(r::AbstractRange{T}) where {T}
1372+
a = Vector{T}(undef, length(r))
1373+
i = 1
1374+
for x in r
1375+
@inbounds a[i] = x
1376+
i += 1
1377+
end
1378+
return a
1379+
end
1380+
collect(r::AbstractRange) = Array(r)
13681381

13691382
_reverse(r::OrdinalRange, ::Colon) = (:)(last(r), negate(step(r)), first(r))
13701383
function _reverse(r::StepRangeLen, ::Colon)

base/reflection.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,12 +1913,15 @@ end
19131913
"""
19141914
@invokelatest f(args...; kwargs...)
19151915
1916-
Provides a convenient way to call [`Base.invokelatest`](@ref).
1916+
Provides a convenient way to call [`invokelatest`](@ref).
19171917
`@invokelatest f(args...; kwargs...)` will simply be expanded into
19181918
`Base.invokelatest(f, args...; kwargs...)`.
19191919
19201920
!!! compat "Julia 1.7"
19211921
This macro requires Julia 1.7 or later.
1922+
1923+
!!! compat "Julia 1.9"
1924+
Prior to Julia 1.9, this macro was not exported, and was called as `Base.@invokelatest`.
19221925
"""
19231926
macro invokelatest(ex)
19241927
f, args, kwargs = destructure_callex(ex)

base/threadingconstructs.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,13 @@ function threading_run(fun, static)
138138
for i = 1:n
139139
t = Task(() -> fun(i)) # pass in tid
140140
t.sticky = static
141-
static && ccall(:jl_set_task_tid, Cint, (Any, Cint), t, tid_offset + i-1)
141+
if static
142+
ccall(:jl_set_task_tid, Cint, (Any, Cint), t, tid_offset + i-1)
143+
else
144+
# TODO: this should be the current pool (except interactive) if there
145+
# are ever more than two pools.
146+
ccall(:jl_set_task_threadpoolid, Cint, (Any, Int8), t, _sym_to_tpid(:default))
147+
end
142148
tasks[i] = t
143149
schedule(t)
144150
end

doc/src/base/base.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ Base.identify_package
449449
Base.locate_package
450450
Base.require
451451
Base.compilecache
452+
Base.get_extension
452453
```
453454

454455
## Internals

doc/src/devdocs/inference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
to the process of deducing the types of later values from the types of
77
input values. Julia's approach to inference has been described in blog
88
posts
9-
([1](https://juliacomputing.com/blog/2016/04/inference-convergence/),
10-
[2](https://juliacomputing.com/blog/2017/05/inference-converage2/)).
9+
([1](https://info.juliahub.com/inference-convergence-algorithm-in-julia/),
10+
[2](https://info.juliahub.com/inference-convergence-algorithm-in-julia-revisited/)).
1111

1212
## Debugging compiler.jl
1313

0 commit comments

Comments
 (0)