Skip to content

Commit 5be4692

Browse files
authored
Backports for julia 1.11.6 (#58224)
2 parents bd445fa + ca6e7bd commit 5be4692

Some content is hidden

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

69 files changed

+730
-214
lines changed

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ and installing Julia, below.
4343
## Resources
4444

4545
- **Homepage:** <https://julialang.org>
46-
- **Binaries:** <https://julialang.org/downloads/>
46+
- **Install:** <https://julialang.org/install/>
4747
- **Source code:** <https://github.com/JuliaLang/julia>
4848
- **Documentation:** <https://docs.julialang.org>
4949
- **Packages:** <https://julialang.org/packages/>
@@ -65,17 +65,22 @@ helpful to start contributing to the Julia codebase.
6565

6666
## Binary Installation
6767

68-
If you would rather not compile the latest Julia from source,
69-
platform-specific tarballs with pre-compiled binaries are also
70-
[available for download](https://julialang.org/downloads/). The
71-
downloads page also provides details on the
72-
[different tiers of support](https://julialang.org/downloads/#supported_platforms)
73-
for OS and platform combinations.
74-
75-
If everything works correctly, you will see a Julia banner and an
76-
interactive prompt into which you can enter expressions for
77-
evaluation. You can read about [getting
78-
started](https://docs.julialang.org/en/v1/manual/getting-started/) in the manual.
68+
The recommended way of installing Julia is to use `juliaup` which will install
69+
the latest stable `julia` for you and help keep it up to date. It can also let
70+
you install and run different Julia versions simultaneously. Instructions for
71+
this can be find [here](https://julialang.org/install/). If you want to manually
72+
download specific Julia binaries, you can find those on the [downloads
73+
page](https://julialang.org/downloads/). The downloads page also provides
74+
details on the [different tiers of
75+
support](https://julialang.org/downloads/#supported_platforms) for OS and
76+
platform combinations.
77+
78+
If everything works correctly, you will get a `julia` program and when you run
79+
it in a terminal or command prompt, you will see a Julia banner and an
80+
interactive prompt into which you can enter expressions for evaluation. You can
81+
read about [getting
82+
started](https://docs.julialang.org/en/v1/manual/getting-started/) in the
83+
manual.
7984

8085
**Note**: Although some OS package managers provide Julia, such
8186
installations are neither maintained nor endorsed by the Julia

base/Base.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ end
151151
"""
152152
time_ns() -> UInt64
153153
154-
Get the time in nanoseconds. The time corresponding to 0 is undefined, and wraps every 5.8 years.
154+
Get the time in nanoseconds relative to some machine-specific arbitrary time in the past.
155+
The primary use is for measuring elapsed times during program execution. The return value is guaranteed to
156+
be monotonic (mod 2⁶⁴) while the system is running, and is unaffected by clock drift or changes to local calendar time,
157+
but it may change arbitrarily across system reboots or suspensions.
158+
159+
(Although the returned time is always in nanoseconds, the timing resolution is platform-dependent.)
155160
"""
156161
time_ns() = ccall(:jl_hrtime, UInt64, ())
157162

base/abstractarray.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,12 +3420,19 @@ function ith_all(i, as)
34203420
end
34213421

34223422
function map_n!(f::F, dest::AbstractArray, As) where F
3423-
idxs1 = LinearIndices(As[1])
3424-
@boundscheck LinearIndices(dest) == idxs1 && all(x -> LinearIndices(x) == idxs1, As)
3425-
for i = idxs1
3426-
@inbounds I = ith_all(i, As)
3427-
val = f(I...)
3428-
@inbounds dest[i] = val
3423+
idxs = LinearIndices(dest)
3424+
if all(x -> LinearIndices(x) == idxs, As)
3425+
for i in idxs
3426+
@inbounds as = ith_all(i, As)
3427+
val = f(as...)
3428+
@inbounds dest[i] = val
3429+
end
3430+
else
3431+
for (i, Is...) in zip(eachindex(dest), map(eachindex, As)...)
3432+
as = ntuple(j->getindex(As[j], Is[j]), length(As))
3433+
val = f(as...)
3434+
dest[i] = val
3435+
end
34293436
end
34303437
return dest
34313438
end

base/accumulate.jl

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
# it does double the number of operations compared to accumulate,
66
# though for cheap operations like + this does not have much impact (20%)
77
function _accumulate_pairwise!(op::Op, c::AbstractVector{T}, v::AbstractVector, s, i1, n)::T where {T,Op}
8-
@inbounds if n < 128
9-
s_ = v[i1]
10-
c[i1] = op(s, s_)
8+
if n < 128
9+
@inbounds s_ = v[i1]
10+
ci1 = op(s, s_)
11+
@inbounds c[i1] = ci1
1112
for i = i1+1:i1+n-1
12-
s_ = op(s_, v[i])
13-
c[i] = op(s, s_)
13+
s_ = op(s_, @inbounds(v[i]))
14+
ci = op(s, s_)
15+
@inbounds c[i] = ci
1416
end
1517
else
1618
n2 = n >> 1
@@ -26,7 +28,8 @@ function accumulate_pairwise!(op::Op, result::AbstractVector, v::AbstractVector)
2628
n = length(li)
2729
n == 0 && return result
2830
i1 = first(li)
29-
@inbounds result[i1] = v1 = reduce_first(op,v[i1])
31+
v1 = reduce_first(op, @inbounds(v[i1]))
32+
@inbounds result[i1] = v1
3033
n == 1 && return result
3134
_accumulate_pairwise!(op, result, v, v1, i1+1, n-1)
3235
return result
@@ -379,16 +382,16 @@ function _accumulate!(op, B, A, dims::Integer, init::Union{Nothing, Some})
379382
# We can accumulate to a temporary variable, which allows
380383
# register usage and will be slightly faster
381384
ind1 = inds_t[1]
382-
@inbounds for I in CartesianIndices(tail(inds_t))
385+
for I in CartesianIndices(tail(inds_t))
383386
if init === nothing
384-
tmp = reduce_first(op, A[first(ind1), I])
387+
tmp = reduce_first(op, @inbounds(A[first(ind1), I]))
385388
else
386-
tmp = op(something(init), A[first(ind1), I])
389+
tmp = op(something(init), @inbounds(A[first(ind1), I]))
387390
end
388-
B[first(ind1), I] = tmp
391+
@inbounds B[first(ind1), I] = tmp
389392
for i_1 = first(ind1)+1:last(ind1)
390-
tmp = op(tmp, A[i_1, I])
391-
B[i_1, I] = tmp
393+
tmp = op(tmp, @inbounds(A[i_1, I]))
394+
@inbounds B[i_1, I] = tmp
392395
end
393396
end
394397
else
@@ -402,25 +405,31 @@ end
402405
@noinline function _accumulaten!(op, B, A, R1, ind, R2, init::Nothing)
403406
# Copy the initial element in each 1d vector along dimension `dim`
404407
ii = first(ind)
405-
@inbounds for J in R2, I in R1
406-
B[I, ii, J] = reduce_first(op, A[I, ii, J])
408+
for J in R2, I in R1
409+
tmp = reduce_first(op, @inbounds(A[I, ii, J]))
410+
@inbounds B[I, ii, J] = tmp
407411
end
408412
# Accumulate
409-
@inbounds for J in R2, i in first(ind)+1:last(ind), I in R1
410-
B[I, i, J] = op(B[I, i-1, J], A[I, i, J])
413+
for J in R2, i in first(ind)+1:last(ind), I in R1
414+
@inbounds Bv, Av = B[I, i-1, J], A[I, i, J]
415+
tmp = op(Bv, Av)
416+
@inbounds B[I, i, J] = tmp
411417
end
412418
B
413419
end
414420

415421
@noinline function _accumulaten!(op, B, A, R1, ind, R2, init::Some)
416422
# Copy the initial element in each 1d vector along dimension `dim`
417423
ii = first(ind)
418-
@inbounds for J in R2, I in R1
419-
B[I, ii, J] = op(something(init), A[I, ii, J])
424+
for J in R2, I in R1
425+
tmp = op(something(init), @inbounds(A[I, ii, J]))
426+
@inbounds B[I, ii, J] = tmp
420427
end
421428
# Accumulate
422-
@inbounds for J in R2, i in first(ind)+1:last(ind), I in R1
423-
B[I, i, J] = op(B[I, i-1, J], A[I, i, J])
429+
for J in R2, i in first(ind)+1:last(ind), I in R1
430+
@inbounds Bv, Av = B[I, i-1, J], A[I, i, J]
431+
tmp = op(Bv, Av)
432+
@inbounds B[I, i, J] = tmp
424433
end
425434
B
426435
end
@@ -434,10 +443,10 @@ function _accumulate1!(op, B, v1, A::AbstractVector, dim::Integer)
434443
cur_val = v1
435444
B[i1] = cur_val
436445
next = iterate(inds, state)
437-
@inbounds while next !== nothing
446+
while next !== nothing
438447
(i, state) = next
439-
cur_val = op(cur_val, A[i])
440-
B[i] = cur_val
448+
cur_val = op(cur_val, @inbounds(A[i]))
449+
@inbounds B[i] = cur_val
441450
next = iterate(inds, state)
442451
end
443452
return B

base/arraymath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ _reverse!(A::AbstractArray{<:Any,N}, ::Colon) where {N} = _reverse!(A, ntuple(id
7272
_reverse!(A, dim::Integer) = _reverse!(A, (Int(dim),))
7373
_reverse!(A, dims::NTuple{M,Integer}) where {M} = _reverse!(A, Int.(dims))
7474
function _reverse!(A::AbstractArray{<:Any,N}, dims::NTuple{M,Int}) where {N,M}
75+
dims === () && return A # nothing to reverse
7576
dimrev = ntuple(k -> k in dims, Val{N}()) # boolean tuple indicating reversed dims
7677

7778
if N < M || M != sum(dimrev)
7879
throw(ArgumentError("invalid dimensions $dims in reverse!"))
7980
end
80-
M == 0 && return A # nothing to reverse
8181

8282
# swapping loop only needs to traverse ≈half of the array
8383
halfsz = ntuple(k -> k == dims[1] ? size(A,k) ÷ 2 : size(A,k), Val{N}())

base/channels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Channel(sz=0) = Channel{Any}(sz)
6161
"""
6262
Channel{T=Any}(func::Function, size=0; taskref=nothing, spawn=false, threadpool=nothing)
6363
64-
Create a new task from `func`, bind it to a new channel of type
64+
Create a new task from `func`, [`bind`](@ref) it to a new channel of type
6565
`T` and size `size`, and schedule the task, all in a single call.
6666
The channel is automatically closed when the task terminates.
6767

base/compiler/ssair/inlining.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn
128128
block = block_for_inst(ir, idx)
129129
inline_into_block!(state, block)
130130

131-
if !isempty(inlinee_cfg.blocks[1].preds)
131+
if length(inlinee_cfg.blocks[1].preds) > 1
132132
need_split_before = true
133+
else
134+
@assert inlinee_cfg.blocks[1].preds[1] == 0
133135
end
134-
135136
last_block_idx = last(state.cfg.blocks[block].stmts)
136137
if false # TODO: ((idx+1) == last_block_idx && isa(ir[SSAValue(last_block_idx)], GotoNode))
137138
need_split = false
@@ -168,12 +169,18 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn
168169
end
169170
new_block_range = (length(state.new_cfg_blocks)-length(inlinee_cfg.blocks)+1):length(state.new_cfg_blocks)
170171

171-
# Fixup the edges of the newely added blocks
172+
# Fixup the edges of the newly added blocks
172173
for (old_block, new_block) in enumerate(bb_rename_range)
173174
if old_block != 1 || need_split_before
174175
p = state.new_cfg_blocks[new_block].preds
175176
let bb_rename_range = bb_rename_range
176177
map!(p, p) do old_pred_block
178+
# the meaning of predecessor 0 depends on the block we encounter it:
179+
# - in the first block, it represents the function entry and so needs to be re-mapped
180+
if old_block == 1 && old_pred_block == 0
181+
return first(bb_rename_range) - 1
182+
end
183+
# - elsewhere, it represents external control-flow from a caught exception which is un-affected by inlining
177184
return old_pred_block == 0 ? 0 : bb_rename_range[old_pred_block]
178185
end
179186
end
@@ -188,10 +195,6 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn
188195
end
189196
end
190197

191-
if need_split_before
192-
push!(state.new_cfg_blocks[first(bb_rename_range)].preds, first(bb_rename_range)-1)
193-
end
194-
195198
any_edges = false
196199
for (old_block, new_block) in enumerate(bb_rename_range)
197200
if (length(state.new_cfg_blocks[new_block].succs) == 0)
@@ -437,7 +440,7 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
437440
else
438441
bb_offset, post_bb_id = popfirst!(todo_bbs)
439442
# This implements the need_split_before flag above
440-
need_split_before = !isempty(item.ir.cfg.blocks[1].preds)
443+
need_split_before = length(item.ir.cfg.blocks[1].preds) > 1
441444
if need_split_before
442445
finish_current_bb!(compact, 0)
443446
end

base/compiler/ssair/ir.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ function compute_basic_blocks(stmts::Vector{Any})
106106
end
107107
# Compute successors/predecessors
108108
for (num, b) in enumerate(blocks)
109+
if b.stmts.start == 1
110+
push!(b.preds, 0) # the entry block has a virtual predecessor
111+
end
109112
terminator = stmts[last(b.stmts)]
110113
if isa(terminator, ReturnNode)
111114
# return never has any successors

base/compiler/typeinfer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ function cache_result!(interp::AbstractInterpreter, result::InferenceResult)
435435
code_cache(interp)[mi] = ci = CodeInstance(interp, result, valid_worlds)
436436
if track_newly_inferred[]
437437
m = mi.def
438-
if isa(m, Method) && m.module != Core
438+
if isa(m, Method)
439439
ccall(:jl_push_newly_inferred, Cvoid, (Any,), ci)
440440
end
441441
end

base/exports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ public
11211121
DL_LOAD_PATH,
11221122
load_path,
11231123
active_project,
1124+
get_extension,
11241125

11251126
# Reflection and introspection
11261127
isambiguous,

0 commit comments

Comments
 (0)