Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: JuliaLang/julia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0bb8e7d90c2edb886e3e3ca70a66cd89797f2e7e
Choose a base ref
..
head repository: JuliaLang/julia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ec1d492e21514638200c28e951f3d8b0e5592048
Choose a head ref
Showing with 1,180 additions and 820 deletions.
  1. +5 −0 NEWS.md
  2. +9 −16 README.md
  3. +9 −12 base/abstractarray.jl
  4. +1 −1 base/broadcast.jl
  5. +10 −2 base/checked.jl
  6. +1 −1 base/compiler/optimize.jl
  7. +3 −0 base/deprecated.jl
  8. +1 −7 base/indices.jl
  9. +28 −1 base/meta.jl
  10. +1 −1 base/multidimensional.jl
  11. +108 −39 base/range.jl
  12. +1 −1 base/reflection.jl
  13. +2 −2 base/reinterpretarray.jl
  14. +3 −3 base/show.jl
  15. +5 −5 base/subarray.jl
  16. +14 −0 base/task.jl
  17. +4 −4 deps/Versions.make
  18. +0 −1 deps/checksums/Pkg-9914dabfd66813197e0c67e28b78cfe0b393fe88.tar.gz/md5
  19. +0 −1 deps/checksums/Pkg-9914dabfd66813197e0c67e28b78cfe0b393fe88.tar.gz/sha512
  20. +1 −0 deps/checksums/Pkg-e476cd0c61e19b645cc0e32bb30f8e44f60001f7.tar.gz/md5
  21. +1 −0 deps/checksums/Pkg-e476cd0c61e19b645cc0e32bb30f8e44f60001f7.tar.gz/sha512
  22. +58 −58 deps/checksums/clang
  23. +240 −232 deps/checksums/llvm
  24. +2 −0 deps/llvm.mk
  25. +158 −0 deps/patches/llvm-12-fde-symbols-aarch64.patch
  26. +31 −0 deps/patches/llvm-12-force-eh_frame-aarch64.patch
  27. +1 −0 doc/src/base/collections.md
  28. +1 −1 doc/src/devdocs/eval.md
  29. +1 −1 doc/src/manual/mathematical-operations.md
  30. +1 −1 src/Makefile
  31. +12 −9 src/array.c
  32. +5 −1 src/ast.scm
  33. +16 −13 src/julia-syntax.scm
  34. +1 −0 src/julia_internal.h
  35. +0 −291 src/llvm-api.cpp
  36. +6 −2 src/options.h
  37. +1 −1 src/partr.c
  38. +29 −16 src/staticdata.c
  39. +2 −6 src/task.c
  40. +1 −1 stdlib/Dates/test/ranges.jl
  41. +2 −2 stdlib/Distributed/src/remotecall.jl
  42. +1 −0 stdlib/InteractiveUtils/src/editless.jl
  43. +5 −0 stdlib/LinearAlgebra/src/LinearAlgebra.jl
  44. +105 −3 stdlib/LinearAlgebra/src/triangular.jl
  45. +35 −0 stdlib/LinearAlgebra/test/triangular.jl
  46. +1 −1 stdlib/Pkg.version
  47. +1 −1 stdlib/Test/src/Test.jl
  48. +1 −1 stdlib/libLLVM_jll/Project.toml
  49. +11 −1 test/arrayops.jl
  50. +10 −2 test/cmdlineargs.jl
  51. +7 −0 test/keywordargs.jl
  52. +26 −4 test/meta.jl
  53. +11 −0 test/misc.jl
  54. +157 −60 test/ranges.jl
  55. +12 −0 test/syntax.jl
  56. +6 −9 test/testhelpers/Furlongs.jl
  57. +3 −5 test/testhelpers/InfiniteArrays.jl
  58. +0 −1 test/testhelpers/OffsetArrays.jl
  59. +13 −0 test/threads_exec.jl
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -39,6 +39,11 @@ New library features
Standard library changes
------------------------

* The `length` function on certain ranges of certain specific element types no longer checks for integer
overflow in most cases. The new function `checked_length` is now available, which will try to use checked
arithmetic to error if the result may be wrapping. Or use a package such as SaferIntegers.jl when
constructing the range. ([#40382])

#### Package Manager

#### LinearAlgebra
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,16 @@
Documentation:
[![version 1][docs-img]](https://docs.julialang.org)

Code coverage:
[![coveralls][coveralls-img]](https://coveralls.io/r/JuliaLang/julia?branch=master)
[![codecov][codecov-img]](https://codecov.io/github/JuliaLang/julia?branch=master)

Continuous integration: [![Build status](https://badge.buildkite.com/f28e0d28b345f9fad5856ce6a8d64fffc7c70df8f4f2685cd8.svg?branch=master)](https://buildkite.com/julialang/julia)

[docs-img]: https://img.shields.io/badge/docs-v1-blue.svg
[coveralls-img]: https://img.shields.io/coveralls/github/JuliaLang/julia/master.svg?label=coveralls
[codecov-img]: https://img.shields.io/codecov/c/github/JuliaLang/julia/master.svg?label=codecov


## The Julia Language

@@ -141,19 +150,3 @@ Supported IDEs include: [julia-vscode](https://github.com/JuliaEditorSupport/jul
Code plugin), [Juno](http://junolab.org/) (Atom plugin). [Jupyter](https://jupyter.org/)
notebooks are available through the [IJulia](https://github.com/JuliaLang/IJulia.jl) package, and
[Pluto](https://github.com/fonsp/Pluto.jl) notebooks through the Pluto.jl package.

## Continuous Integration (CI) Builders

Code coverage:
[![coveralls][coveralls-img]](https://coveralls.io/r/JuliaLang/julia?branch=master)
[![codecov][codecov-img]](https://codecov.io/github/JuliaLang/julia?branch=master)

| Builder | Status |
| ---------- | ------ |
| Overall | [![Build status](https://badge.buildkite.com/f28e0d28b345f9fad5856ce6a8d64fffc7c70df8f4f2685cd8.svg?branch=master)](https://buildkite.com/julialang/julia) |
| analyzegc | [![Build status](https://badge.buildkite.com/f28e0d28b345f9fad5856ce6a8d64fffc7c70df8f4f2685cd8.svg?branch=master&step=analyzegc)](https://buildkite.com/julialang/julia) |
| llvmpasses | [![Build status](https://badge.buildkite.com/f28e0d28b345f9fad5856ce6a8d64fffc7c70df8f4f2685cd8.svg?branch=master&step=llvmpasses)](https://buildkite.com/julialang/julia) |
| coverage | [![Build status](https://badge.buildkite.com/d5ae34dbbf6fefe615300c4f3118bf63cb4a5ae7fd962263c1.svg?branch=master)](https://buildkite.com/julialang/julia-coverage-linux64) |

[coveralls-img]: https://img.shields.io/coveralls/github/JuliaLang/julia/master.svg?label=coveralls
[codecov-img]: https://img.shields.io/codecov/c/github/JuliaLang/julia/master.svg?label=codecov
21 changes: 9 additions & 12 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
@@ -116,9 +116,6 @@ axes1(A::AbstractArray{<:Any,0}) = OneTo(1)
axes1(A::AbstractArray) = (@_inline_meta; axes(A)[1])
axes1(iter) = oneto(length(iter))

unsafe_indices(A) = axes(A)
unsafe_indices(r::AbstractRange) = (oneto(unsafe_length(r)),) # Ranges use checked_sub for size

"""
keys(a::AbstractArray)
@@ -580,14 +577,14 @@ end
function trailingsize(inds::Indices, n)
s = 1
for i=n:length(inds)
s *= unsafe_length(inds[i])
s *= length(inds[i])
end
return s
end
# This version is type-stable even if inds is heterogeneous
function trailingsize(inds::Indices)
@_inline_meta
prod(map(unsafe_length, inds))
prod(map(length, inds))
end

## Bounds checking ##
@@ -688,7 +685,7 @@ function checkbounds_indices(::Type{Bool}, ::Tuple{}, I::Tuple)
@_inline_meta
checkindex(Bool, OneTo(1), I[1])::Bool & checkbounds_indices(Bool, (), tail(I))
end
checkbounds_indices(::Type{Bool}, IA::Tuple, ::Tuple{}) = (@_inline_meta; all(x->unsafe_length(x)==1, IA))
checkbounds_indices(::Type{Bool}, IA::Tuple, ::Tuple{}) = (@_inline_meta; all(x->length(x)==1, IA))
checkbounds_indices(::Type{Bool}, ::Tuple{}, ::Tuple{}) = true

throw_boundserror(A, I) = (@_noinline_meta; throw(BoundsError(A, I)))
@@ -1133,7 +1130,7 @@ function copymutable(a::AbstractArray)
end
copymutable(itr) = collect(itr)

zero(x::AbstractArray{T}) where {T} = fill!(similar(x), zero(T))
zero(x::AbstractArray{T}) where {T} = fill!(similar(x, typeof(zero(T))), zero(T))

## iteration support for arrays by iterating over `eachindex` in the array ##
# Allows fast iteration by default for both IndexLinear and IndexCartesian arrays
@@ -2300,8 +2297,8 @@ function _typed_hvncat(::Type{T}, dims::Tuple{Vararg{Int, N}}, row_first::Bool,
len += cat_length(a)
end
outlen = prod(outdims)
outlen == 0 && ArgumentError("too few elements in arguments, unable to infer dimensions") |> throw
len == outlen || ArgumentError("too many elements in arguments; expected $(outlen), got $(len)") |> throw
outlen == 0 && throw(ArgumentError("too few elements in arguments, unable to infer dimensions"))
len == outlen || throw(ArgumentError("too many elements in arguments; expected $(outlen), got $(len)"))

# copy into final array
A = cat_similar(as[1], T, outdims)
@@ -2499,8 +2496,8 @@ function _sub2ind_recurse(inds, L, ind, i::Integer, I::Integer...)
end

nextL(L, l::Integer) = L*l
nextL(L, r::AbstractUnitRange) = L*unsafe_length(r)
nextL(L, r::Slice) = L*unsafe_length(r.indices)
nextL(L, r::AbstractUnitRange) = L*length(r)
nextL(L, r::Slice) = L*length(r.indices)
offsetin(i, l::Integer) = i-1
offsetin(i, r::AbstractUnitRange) = i-first(r)

@@ -2526,7 +2523,7 @@ end
_lookup(ind, d::Integer) = ind+1
_lookup(ind, r::AbstractUnitRange) = ind+first(r)
_div(ind, d::Integer) = div(ind, d), 1, d
_div(ind, r::AbstractUnitRange) = (d = unsafe_length(r); (div(ind, d), first(r), d))
_div(ind, r::AbstractUnitRange) = (d = length(r); (div(ind, d), first(r), d))

# Vectorized forms
function _sub2ind(inds::Indices{1}, I1::AbstractVector{T}, I::AbstractVector{T}...) where T<:Integer
2 changes: 1 addition & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
@@ -566,7 +566,7 @@ an `Int`.
"""
Base.@propagate_inbounds newindex(arg, I::CartesianIndex) = CartesianIndex(_newindex(axes(arg), I.I))
Base.@propagate_inbounds newindex(arg, I::Integer) = CartesianIndex(_newindex(axes(arg), (I,)))
Base.@propagate_inbounds _newindex(ax::Tuple, I::Tuple) = (ifelse(Base.unsafe_length(ax[1])==1, ax[1][1], I[1]), _newindex(tail(ax), tail(I))...)
Base.@propagate_inbounds _newindex(ax::Tuple, I::Tuple) = (ifelse(length(ax[1]) == 1, ax[1][1], I[1]), _newindex(tail(ax), tail(I))...)
Base.@propagate_inbounds _newindex(ax::Tuple{}, I::Tuple) = ()
Base.@propagate_inbounds _newindex(ax::Tuple, I::Tuple{}) = (ax[1][1], _newindex(tail(ax), ())...)
Base.@propagate_inbounds _newindex(ax::Tuple{}, I::Tuple{}) = ()
12 changes: 10 additions & 2 deletions base/checked.jl
Original file line number Diff line number Diff line change
@@ -6,14 +6,14 @@ module Checked

export checked_neg, checked_abs, checked_add, checked_sub, checked_mul,
checked_div, checked_rem, checked_fld, checked_mod, checked_cld,
add_with_overflow, sub_with_overflow, mul_with_overflow
checked_length, add_with_overflow, sub_with_overflow, mul_with_overflow

import Core.Intrinsics:
checked_sadd_int, checked_ssub_int, checked_smul_int, checked_sdiv_int,
checked_srem_int,
checked_uadd_int, checked_usub_int, checked_umul_int, checked_udiv_int,
checked_urem_int
import ..no_op_err, ..@_inline_meta, ..@_noinline_meta
import ..no_op_err, ..@_inline_meta, ..@_noinline_meta, ..checked_length

# define promotion behavior for checked operations
checked_add(x::Integer, y::Integer) = checked_add(promote(x,y)...)
@@ -349,4 +349,12 @@ The overflow protection may impose a perceptible performance penalty.
"""
checked_cld(x::T, y::T) where {T<:Integer} = cld(x, y) # Base.cld already checks

"""
Base.checked_length(r)
Calculates `length(r)`, but may check for overflow errors where applicable when
the result doesn't fit into `Union{Integer(eltype(r)),Int}`.
"""
checked_length(r) = length(r) # for most things, length doesn't error

end
2 changes: 1 addition & 1 deletion base/compiler/optimize.jl
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ function isinlineable(m::Method, me::OptimizationState, params::OptimizationPara
end
end
if !inlineable
inlineable = inline_worthy(me.ir, params, union_penalties, cost_threshold + bonus)
inlineable = inline_worthy(me.ir::IRCode, params, union_penalties, cost_threshold + bonus)
end
return inlineable
end
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
@@ -240,6 +240,9 @@ end
@deprecate cat_shape(dims, shape::Tuple{}, shapes::Tuple...) cat_shape(dims, shapes) false
cat_shape(dims, shape::Tuple{}) = () # make sure `cat_shape(dims, ())` do not recursively calls itself

@deprecate unsafe_indices(A) axes(A) false
@deprecate unsafe_length(r) length(r) false

# END 1.6 deprecations

# BEGIN 1.7 deprecations
8 changes: 1 addition & 7 deletions base/indices.jl
Original file line number Diff line number Diff line change
@@ -352,17 +352,14 @@ struct Slice{T<:AbstractUnitRange} <: AbstractUnitRange{Int}
end
Slice(S::Slice) = S
axes(S::Slice) = (IdentityUnitRange(S.indices),)
unsafe_indices(S::Slice) = (IdentityUnitRange(S.indices),)
axes1(S::Slice) = IdentityUnitRange(S.indices)
axes(S::Slice{<:OneTo}) = (S.indices,)
unsafe_indices(S::Slice{<:OneTo}) = (S.indices,)
axes1(S::Slice{<:OneTo}) = S.indices

first(S::Slice) = first(S.indices)
last(S::Slice) = last(S.indices)
size(S::Slice) = (length(S.indices),)
length(S::Slice) = length(S.indices)
unsafe_length(S::Slice) = unsafe_length(S.indices)
getindex(S::Slice, i::Int) = (@_inline_meta; @boundscheck checkbounds(S, i); i)
getindex(S::Slice, i::AbstractUnitRange{<:Integer}) = (@_inline_meta; @boundscheck checkbounds(S, i); i)
getindex(S::Slice, i::StepRange{<:Integer}) = (@_inline_meta; @boundscheck checkbounds(S, i); i)
@@ -383,17 +380,14 @@ end
IdentityUnitRange(S::IdentityUnitRange) = S
# IdentityUnitRanges are offset and thus have offset axes, so they are their own axes
axes(S::IdentityUnitRange) = (S,)
unsafe_indices(S::IdentityUnitRange) = (S,)
axes1(S::IdentityUnitRange) = S
axes(S::IdentityUnitRange{<:OneTo}) = (S.indices,)
unsafe_indices(S::IdentityUnitRange{<:OneTo}) = (S.indices,)
axes1(S::IdentityUnitRange{<:OneTo}) = S.indices

first(S::IdentityUnitRange) = first(S.indices)
last(S::IdentityUnitRange) = last(S.indices)
size(S::IdentityUnitRange) = (length(S.indices),)
length(S::IdentityUnitRange) = length(S.indices)
unsafe_length(S::IdentityUnitRange) = unsafe_length(S.indices)
getindex(S::IdentityUnitRange, i::Int) = (@_inline_meta; @boundscheck checkbounds(S, i); i)
getindex(S::IdentityUnitRange, i::AbstractUnitRange{<:Integer}) = (@_inline_meta; @boundscheck checkbounds(S, i); i)
getindex(S::IdentityUnitRange, i::StepRange{<:Integer}) = (@_inline_meta; @boundscheck checkbounds(S, i); i)
@@ -479,7 +473,7 @@ convert(::Type{LinearIndices{N,R}}, inds::LinearIndices{N}) where {N,R} =
# AbstractArray implementation
IndexStyle(::Type{<:LinearIndices}) = IndexLinear()
axes(iter::LinearIndices) = map(axes1, iter.indices)
size(iter::LinearIndices) = map(unsafe_length, iter.indices)
size(iter::LinearIndices) = map(length, iter.indices)
function getindex(iter::LinearIndices, i::Int)
@_inline_meta
@boundscheck checkbounds(iter, i)
29 changes: 28 additions & 1 deletion base/meta.jl
Original file line number Diff line number Diff line change
@@ -370,7 +370,10 @@ function _partially_inline!(@nospecialize(x), slot_replacements::Vector{Any},
if isa(x, Expr)
head = x.head
if head === :static_parameter
return QuoteNode(static_param_values[x.args[1]])
if isassigned(static_param_values, x.args[1])
return QuoteNode(static_param_values[x.args[1]])
end
return x
elseif head === :cfunction
@assert !isa(type_signature, UnionAll) || !isempty(spvals)
if !isa(x.args[2], QuoteNode) # very common no-op
@@ -413,6 +416,30 @@ function _partially_inline!(@nospecialize(x), slot_replacements::Vector{Any},
x.args[2] += statement_offset
elseif head === :enter
x.args[1] += statement_offset
elseif head === :isdefined
arg = x.args[1]
# inlining a QuoteNode or literal into `Expr(:isdefined, x)` is invalid, replace with true
if isa(arg, Core.SlotNumber)
id = arg.id
if 1 <= id <= length(slot_replacements)
replacement = slot_replacements[id]
if isa(replacement, Union{Core.SlotNumber, GlobalRef, Symbol})
return Expr(:isdefined, replacement)
else
@assert !isa(replacement, Expr)
return true
end
end
return Expr(:isdefined, Core.SlotNumber(id + slot_offset))
elseif isexpr(arg, :static_parameter)
if isassigned(static_param_values, arg.args[1])
return true
end
return x
else
@assert isa(arg, Union{GlobalRef, Symbol})
return x
end
elseif !is_meta_expr_head(head)
partially_inline!(x.args, slot_replacements, type_signature, static_param_values,
slot_offset, statement_offset, boundscheck)
2 changes: 1 addition & 1 deletion base/multidimensional.jl
Original file line number Diff line number Diff line change
@@ -849,7 +849,7 @@ function _unsafe_getindex(::IndexStyle, A::AbstractArray, I::Vararg{Union{Real,
# This is specifically not inlined to prevent excessive allocations in type unstable code
shape = index_shape(I...)
dest = similar(A, shape)
map(unsafe_length, axes(dest)) == map(unsafe_length, shape) || throw_checksize_error(dest, shape)
map(length, axes(dest)) == map(length, shape) || throw_checksize_error(dest, shape)
_unsafe_getindex!(dest, A, I...) # usually a generated function, don't allow it to impact inference result
return dest
end
Loading