Skip to content

Commit

Permalink
Merge branch 'master' into source-build--zlib
Browse files Browse the repository at this point in the history
  • Loading branch information
inkydragon committed Jul 6, 2022
2 parents b363bd5 + c5aa255 commit aa7d881
Show file tree
Hide file tree
Showing 45 changed files with 255 additions and 135 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
JULIAHOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
include $(JULIAHOME)/Make.inc
# import LLVM_SHARED_LIB_NAME
include $(JULIAHOME)/deps/llvm-ver.make

VERSDIR := v`cut -d. -f1-2 < $(JULIAHOME)/VERSION`

Expand Down Expand Up @@ -197,7 +199,7 @@ else
JL_PRIVATE_LIBS-$(USE_SYSTEM_ZLIB) += libz
endif
ifeq ($(USE_LLVM_SHLIB),1)
JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM libLLVM-14jl
JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM $(LLVM_SHARED_LIB_NAME)
endif
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBUNWIND) += libunwind

Expand Down
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ function copyto_unaliased!(deststyle::IndexStyle, dest::AbstractArray, srcstyle:
# Dual-iterator implementation
ret = iterate(iterdest)
@inbounds for a in src
idx, state = ret
idx, state = ret::NTuple{2,Any}
dest[idx] = a
ret = iterate(iterdest, state)
end
Expand Down
2 changes: 1 addition & 1 deletion base/atomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export
# - LLVM doesn't currently support atomics on floats for ppc64
# C++20 is adding limited support for atomics on float, but as of
# now Clang does not support that yet.
if Sys.ARCH == :i686 || startswith(string(Sys.ARCH), "arm") ||
if Sys.ARCH === :i686 || startswith(string(Sys.ARCH), "arm") ||
Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
const inttypes = (Int8, Int16, Int32, Int64,
UInt8, UInt16, UInt32, UInt64)
Expand Down
2 changes: 1 addition & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ Base.@propagate_inbounds dotview(B::BitArray, i::BitArray) = BitMaskedBitArray(B
Base.show(io::IO, B::BitMaskedBitArray) = foreach(arg->show(io, arg), (typeof(B), (B.parent, B.mask)))
# Override materialize! to prevent the BitMaskedBitArray from escaping to an overrideable method
@inline materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any,<:Any,typeof(identity),Tuple{Bool}}) = fill!(B, bc.args[1])
@inline materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any}) = materialize!(SubArray(B.parent, to_indices(B.parent, (B.mask,))), bc)
@inline materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any}) = materialize!(@inbounds(view(B.parent, B.mask)), bc)
function Base.fill!(B::BitMaskedBitArray, b::Bool)
Bc = B.parent.chunks
Ic = B.mask.chunks
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ function statement_cost(ex::Expr, line::Int, src::Union{CodeInfo, IRCode}, sptyp
return 0
end
return error_path ? params.inline_error_path_cost : params.inline_nonleaf_penalty
elseif head === :foreigncall || head === :invoke || head == :invoke_modify
elseif head === :foreigncall || head === :invoke || head === :invoke_modify
# Calls whose "return type" is Union{} do not actually return:
# they are errors. Since these are not part of the typical
# run-time of the function, we omit them from
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/ssair/slot2ssa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ function domsort_ssa!(ir::IRCode, domtree::DomTree)
result[inst_range[end]][:inst] = GotoIfNot(terminator.cond, bb_rename[terminator.dest])
elseif !isa(terminator, ReturnNode)
if isa(terminator, Expr)
if terminator.head == :enter
if terminator.head === :enter
terminator.args[1] = bb_rename[terminator.args[1]]
end
end
Expand Down
72 changes: 36 additions & 36 deletions base/div.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"""
div(x, y, r::RoundingMode=RoundToZero)
The quotient from Euclidean (integer) division. Computes x/y, rounded to
The quotient from Euclidean (integer) division. Computes `x / y`, rounded to
an integer according to the rounding mode `r`. In other words, the quantity
round(x/y,r)
round(x / y, r)
without any intermediate rounding.
Expand Down Expand Up @@ -52,12 +52,12 @@ div(a, b) = div(a, b, RoundToZero)
Compute the remainder of `x` after integer division by `y`, with the quotient rounded
according to the rounding mode `r`. In other words, the quantity
x - y*round(x/y,r)
x - y * round(x / y, r)
without any intermediate rounding.
- if `r == RoundNearest`, then the result is exact, and in the interval
``[-|y|/2, |y|/2]``. See also [`RoundNearest`](@ref).
``[-|y| / 2, |y| / 2]``. See also [`RoundNearest`](@ref).
- if `r == RoundToZero` (default), then the result is exact, and in the interval
``[0, |y|)`` if `x` is positive, or ``(-|y|, 0]`` otherwise. See also [`RoundToZero`](@ref).
Expand All @@ -66,12 +66,12 @@ without any intermediate rounding.
``(y, 0]`` otherwise. The result may not be exact if `x` and `y` have different signs, and
`abs(x) < abs(y)`. See also [`RoundDown`](@ref).
- if `r == RoundUp`, then the result is in the interval `(-y,0]` if `y` is positive, or
`[0,-y)` otherwise. The result may not be exact if `x` and `y` have the same sign, and
- if `r == RoundUp`, then the result is in the interval ``(-y, 0]`` if `y` is positive, or
``[0, -y)`` otherwise. The result may not be exact if `x` and `y` have the same sign, and
`abs(x) < abs(y)`. See also [`RoundUp`](@ref).
- if `r == RoundFromZero`, then the result is in the interval `(-y, 0]` if `y` is positive, or
`[0, -y)` otherwise. The result may not be exact if `x` and `y` have the same sign, and
- if `r == RoundFromZero`, then the result is in the interval ``(-y, 0]`` if `y` is positive, or
``[0, -y)`` otherwise. The result may not be exact if `x` and `y` have the same sign, and
`abs(x) < abs(y)`. See also [`RoundFromZero`](@ref).
!!! compat "Julia 1.9"
Expand All @@ -97,7 +97,7 @@ rem(x, y, r::RoundingMode)
rem(x, y, ::RoundingMode{:ToZero}) = rem(x, y)
rem(x, y, ::RoundingMode{:Down}) = mod(x, y)
rem(x, y, ::RoundingMode{:Up}) = mod(x, -y)
rem(x, y, r::RoundingMode{:Nearest}) = x - y*div(x, y, r)
rem(x, y, r::RoundingMode{:Nearest}) = x - y * div(x, y, r)
rem(x::Integer, y::Integer, r::RoundingMode{:Nearest}) = divrem(x, y, r)[2]

function rem(x, y, ::typeof(RoundFromZero))
Expand All @@ -107,13 +107,13 @@ end
"""
fld(x, y)
Largest integer less than or equal to `x/y`. Equivalent to `div(x, y, RoundDown)`.
Largest integer less than or equal to `x / y`. Equivalent to `div(x, y, RoundDown)`.
See also [`div`](@ref), [`cld`](@ref), [`fld1`](@ref).
# Examples
```jldoctest
julia> fld(7.3,5.5)
julia> fld(7.3, 5.5)
1.0
julia> fld.(-5:5, 3)'
Expand All @@ -123,11 +123,11 @@ julia> fld.(-5:5, 3)'
Because `fld(x, y)` implements strictly correct floored rounding based on the true
value of floating-point numbers, unintuitive situations can arise. For example:
```jldoctest
julia> fld(6.0,0.1)
julia> fld(6.0, 0.1)
59.0
julia> 6.0/0.1
julia> 6.0 / 0.1
60.0
julia> 6.0/big(0.1)
julia> 6.0 / big(0.1)
59.99999999999999666933092612453056361837965690217069245739573412231113406246995
```
What is happening here is that the true value of the floating-point number written
Expand All @@ -141,13 +141,13 @@ fld(a, b) = div(a, b, RoundDown)
"""
cld(x, y)
Smallest integer larger than or equal to `x/y`. Equivalent to `div(x, y, RoundUp)`.
Smallest integer larger than or equal to `x / y`. Equivalent to `div(x, y, RoundUp)`.
See also [`div`](@ref), [`fld`](@ref).
# Examples
```jldoctest
julia> cld(5.5,2.2)
julia> cld(5.5, 2.2)
3.0
julia> cld.(-5:5, 3)'
Expand All @@ -162,17 +162,17 @@ cld(a, b) = div(a, b, RoundUp)
divrem(x, y, r::RoundingMode=RoundToZero)
The quotient and remainder from Euclidean division.
Equivalent to `(div(x,y,r), rem(x,y,r))`. Equivalently, with the default
value of `r`, this call is equivalent to `(x÷y, x%y)`.
Equivalent to `(div(x, y, r), rem(x, y, r))`. Equivalently, with the default
value of `r`, this call is equivalent to `(x ÷ y, x % y)`.
See also: [`fldmod`](@ref), [`cld`](@ref).
# Examples
```jldoctest
julia> divrem(3,7)
julia> divrem(3, 7)
(0, 3)
julia> divrem(7,3)
julia> divrem(7, 3)
(2, 1)
```
"""
Expand All @@ -190,23 +190,24 @@ function divrem(a, b, r::RoundingMode)
(div(a, b, r), rem(a, b, r))
end
end
#avoids calling rem for Integers-Integers (all modes),
#a-d*b not precise for Floats - AbstractFloat, AbstractIrrational. Rationals are still slower
# avoids calling rem for Integers-Integers (all modes),
# a - d * b not precise for Floats - AbstractFloat, AbstractIrrational.
# Rationals are still slower
function divrem(a::Integer, b::Integer, r::Union{typeof(RoundUp),
typeof(RoundDown),
typeof(RoundToZero)})
if r === RoundToZero
# For compat. Remove in 2.0.
d = div(a, b)
(d, a - d*b)
(d, a - d * b)
elseif r === RoundDown
# For compat. Remove in 2.0.
d = fld(a, b)
(d, a - d*b)
(d, a - d * b)
elseif r === RoundUp
# For compat. Remove in 2.0.
d = div(a, b, r)
(d, a - d*b)
(d, a - d * b)
end
end
function divrem(x::Integer, y::Integer, rnd::typeof(RoundNearest))
Expand Down Expand Up @@ -266,11 +267,11 @@ end
fldmod(x, y)
The floored quotient and modulus after division. A convenience wrapper for
`divrem(x, y, RoundDown)`. Equivalent to `(fld(x,y), mod(x,y))`.
`divrem(x, y, RoundDown)`. Equivalent to `(fld(x, y), mod(x, y))`.
See also: [`fld`](@ref), [`cld`](@ref), [`fldmod1`](@ref).
"""
fldmod(x,y) = divrem(x, y, RoundDown)
fldmod(x, y) = divrem(x, y, RoundDown)

# We definite generic rounding methods for other rounding modes in terms of
# RoundToZero.
Expand Down Expand Up @@ -322,11 +323,11 @@ div(a::UInt128, b::UInt128, ::typeof(RoundToZero)) = div(a, b)
rem(a::Int128, b::Int128, ::typeof(RoundToZero)) = rem(a, b)
rem(a::UInt128, b::UInt128, ::typeof(RoundToZero)) = rem(a, b)

# These are kept for compatibility with external packages overriding fld/cld.
# In 2.0, packages should extend div(a,b,r) instead, in which case, these can
# These are kept for compatibility with external packages overriding fld / cld.
# In 2.0, packages should extend div(a, b, r) instead, in which case, these can
# be removed.
fld(x::Real, y::Real) = div(promote(x,y)..., RoundDown)
cld(x::Real, y::Real) = div(promote(x,y)..., RoundUp)
fld(x::Real, y::Real) = div(promote(x, y)..., RoundDown)
cld(x::Real, y::Real) = div(promote(x, y)..., RoundUp)
fld(x::Signed, y::Unsigned) = div(x, y, RoundDown)
fld(x::Unsigned, y::Signed) = div(x, y, RoundDown)
cld(x::Signed, y::Unsigned) = div(x, y, RoundUp)
Expand All @@ -346,14 +347,14 @@ function div(x::Real, y::Real, r::RoundingMode)
end

# Integers
# fld(x,y) == div(x,y) - ((x>=0) != (y>=0) && rem(x,y) != 0 ? 1 : 0)
div(x::T, y::T, ::typeof(RoundDown)) where {T<:Unsigned} = div(x,y)
# fld(x, y) == div(x, y) - ((x >= 0) != (y >= 0) && rem(x, y) != 0 ? 1 : 0)
div(x::T, y::T, ::typeof(RoundDown)) where {T<:Unsigned} = div(x, y)
function div(x::T, y::T, ::typeof(RoundDown)) where T<:Integer
d = div(x, y, RoundToZero)
return d - (signbit(x y) & (d * y != x))
end

# cld(x,y) = div(x,y) + ((x>0) == (y>0) && rem(x,y) != 0 ? 1 : 0)
# cld(x, y) = div(x, y) + ((x > 0) == (y > 0) && rem(x, y) != 0 ? 1 : 0)
function div(x::T, y::T, ::typeof(RoundUp)) where T<:Unsigned
d = div(x, y, RoundToZero)
return d + (d * y != x)
Expand All @@ -366,5 +367,4 @@ end
# Real
# NOTE: C89 fmod() and x87 FPREM implicitly provide truncating float division,
# so it is used here as the basis of float div().
div(x::T, y::T, r::RoundingMode) where {T<:AbstractFloat} = convert(T,round((x-rem(x,y,r))/y))
rem(x::T, y::T, ::typeof(RoundUp)) where {T<:AbstractFloat} = convert(T,x-y*ceil(x/y))
div(x::T, y::T, r::RoundingMode) where {T<:AbstractFloat} = convert(T, round((x - rem(x, y, r)) / y))
2 changes: 1 addition & 1 deletion base/experimental.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ the MethodTable).
"""
macro max_methods(n::Int, fdef::Expr)
0 < n <= 255 || error("We must have that `1 <= max_methods <= 255`, but `max_methods = $n`.")
(fdef.head == :function && length(fdef.args) == 1) || error("Second argument must be a function forward declaration")
(fdef.head === :function && length(fdef.args) == 1) || error("Second argument must be a function forward declaration")
return :(typeof($(esc(fdef))).name.max_methods = $(UInt8(n)))
end

Expand Down
2 changes: 0 additions & 2 deletions base/float.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ muladd(x::T, y::T, z::T) where {T<:IEEEFloat} = muladd_float(x, y, z)

rem(x::T, y::T) where {T<:IEEEFloat} = rem_float(x, y)

cld(x::T, y::T) where {T<:AbstractFloat} = -fld(-x,y)

function mod(x::T, y::T) where T<:AbstractFloat
r = rem(x,y)
if r == 0
Expand Down
1 change: 1 addition & 0 deletions base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@ else
end
end

Stateful(x::Stateful) = x
convert(::Type{Stateful}, itr) = Stateful(itr)

@inline isdone(s::Stateful, st=nothing) = s.nextvalstate === nothing
Expand Down
2 changes: 1 addition & 1 deletion base/meta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ rather than line 2 where `@test` is used as an implementation detail.
"""
function replace_sourceloc!(sourceloc, @nospecialize(ex))
if ex isa Expr
if ex.head == :macrocall
if ex.head === :macrocall
ex.args[2] = sourceloc
end
map!(e -> replace_sourceloc!(sourceloc, e), ex.args, ex.args)
Expand Down
2 changes: 1 addition & 1 deletion base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function show_method_table(io::IO, ms::MethodList, max::Int=-1, header::Bool=tru
last_shown_line_infos = get(io, :last_shown_line_infos, nothing)
last_shown_line_infos === nothing || empty!(last_shown_line_infos)

modul = if mt === _TYPE_NAME.mt # type constructor
modul = if mt === _TYPE_NAME.mt && length(ms) > 0 # type constructor
which(ms.ms[1].module, ms.ms[1].name)
else
mt.module
Expand Down
2 changes: 1 addition & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ function bodyfunction(basemethod::Method)
f = nothing
if isa(ast, Core.CodeInfo) && length(ast.code) >= 2
callexpr = ast.code[end-1]
if isa(callexpr, Expr) && callexpr.head == :call
if isa(callexpr, Expr) && callexpr.head === :call
fsym = callexpr.args[1]
if isa(fsym, Symbol)
f = getfield(fmod, fsym)
Expand Down
24 changes: 8 additions & 16 deletions base/reinterpretarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,15 @@ strides(a::Union{DenseArray,StridedReshapedArray,StridedReinterpretArray}) = siz
stride(A::Union{DenseArray,StridedReshapedArray,StridedReinterpretArray}, k::Integer) =
k ndims(A) ? strides(A)[k] : length(A)

function strides(a::ReshapedReinterpretArray)
ap = parent(a)
els, elp = elsize(a), elsize(ap)
stp = strides(ap)
els == elp && return stp
els < elp && return (1, _checked_strides(stp, els, elp)...)
function strides(a::ReinterpretArray{T,<:Any,S,<:AbstractArray{S},IsReshaped}) where {T,S,IsReshaped}
_checkcontiguous(Bool, a) && return size_to_strides(1, size(a))
stp = strides(parent(a))
els, elp = sizeof(T), sizeof(S)
els == elp && return stp # 0dim parent is also handled here.
IsReshaped && els < elp && return (1, _checked_strides(stp, els, elp)...)
stp[1] == 1 || throw(ArgumentError("Parent must be contiguous in the 1st dimension!"))
return _checked_strides(tail(stp), els, elp)
end

function strides(a::NonReshapedReinterpretArray)
ap = parent(a)
els, elp = elsize(a), elsize(ap)
stp = strides(ap)
els == elp && return stp
stp[1] == 1 || throw(ArgumentError("Parent must be contiguous in the 1st dimension!"))
return (1, _checked_strides(tail(stp), els, elp)...)
st′ = _checked_strides(tail(stp), els, elp)
return IsReshaped ? st′ : (1, st′...)
end

@inline function _checked_strides(stp::Tuple, els::Integer, elp::Integer)
Expand Down
Loading

0 comments on commit aa7d881

Please sign in to comment.