Skip to content

Commit

Permalink
Merge pull request #34238 from JuliaLang/backports-release-1.4
Browse files Browse the repository at this point in the history
Backports for 1.4-RC1
  • Loading branch information
ararslan authored Jan 20, 2020
2 parents 4c58369 + 139696b commit 1c977b0
Show file tree
Hide file tree
Showing 217 changed files with 453 additions and 381 deletions.
2 changes: 1 addition & 1 deletion base/arrayshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ but it also repeated every M elements if desired.
"""
function print_matrix_vdots(io::IO, vdots::AbstractString,
A::Vector, sep::AbstractString, M::Integer, m::Integer,
pad_right::Bool)
pad_right::Bool = true)
for k = 1:length(A)
w = A[k][1] + A[k][2]
if k % M == m
Expand Down
1 change: 1 addition & 0 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ _bcsm(a::Number, b::Number) = a == b || b == 1
# (We may not want to define general promotion rules between, say, OneTo and Slice, but if
# we get here we know the axes are at least consistent for the purposes of broadcasting)
axistype(a::T, b::T) where T = a
axistype(a::OneTo, b::OneTo) = OneTo{Int}(a)
axistype(a, b) = UnitRange{Int}(a)

## Check that all arguments are broadcast compatible with shape
Expand Down
2 changes: 1 addition & 1 deletion base/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Note that the argument type tuple must be a literal tuple, and not a tuple-value
(although it can include a splat expression). And that these arguments will be evaluated in global scope
during compile-time (not deferred until runtime).
Adding a '\\\$' in front of the function argument changes this to instead create a runtime closure
over the local variable `callable`.
over the local variable `callable` (this is not supported on all architectures).
See [manual section on ccall and cfunction usage](@ref Calling-C-and-Fortran-Code).
Expand Down
7 changes: 7 additions & 0 deletions base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
end
elseif isa(leaf, QuoteNode)
leaf = leaf.value
elseif isa(leaf, GlobalRef)
mod, name = leaf.mod, leaf.name
if isdefined(mod, name) && isconst(mod, name)
leaf = getfield(mod, name)
else
return nothing
end
elseif isa(leaf, Union{Argument, Expr})
return nothing
end
Expand Down
16 changes: 12 additions & 4 deletions base/compiler/ssair/verify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function check_op(ir::IRCode, domtree::DomTree, @nospecialize(op), use_bb::Int,
end
else
if !dominates(domtree, def_bb, use_bb) && !(bb_unreachable(domtree, def_bb) && bb_unreachable(domtree, use_bb))
# At the moment, we allow GC preserve tokens outside the standard domination notion
#@Base.show ir
@verify_error "Basic Block $def_bb does not dominate block $use_bb (tried to use value $(op.id))"
error()
Expand Down Expand Up @@ -189,10 +190,17 @@ function verify_ir(ir::IRCode)
end
end
end
if isa(stmt, Expr) && stmt.head === :(=)
if stmt.args[1] isa SSAValue
@verify_error "SSAValue as assignment LHS"
error()
if isa(stmt, Expr)
if stmt.head === :(=)
if stmt.args[1] isa SSAValue
@verify_error "SSAValue as assignment LHS"
error()
end
elseif stmt.head === :gc_preserve_end
# We allow gc_preserve_end tokens to span across try/catch
# blocks, which isn't allowed for regular SSA values, so
# we skip the validation below.
continue
end
end
for op in userefs(stmt)
Expand Down
15 changes: 0 additions & 15 deletions base/compiler/typelimits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,6 @@ function is_derived_type(@nospecialize(t), @nospecialize(c), mindepth::Int)
for p in cP
is_derived_type(t, p, mindepth) && return true
end
if isconcretetype(c) && isbitstype(c)
# see if it was extracted from a fieldtype
# however, only look through types that can be inlined
# to ensure monotonicity of derivation
# since we know that for immutable, concrete, bits types,
# the field types must have been constructed prior to the type,
# it cannot have a reference cycle in the type graph
cF = c.types
for f in cF
# often a parameter is also a field type; avoid searching twice
if !contains_is(c.parameters, f)
is_derived_type(t, f, mindepth) && return true
end
end
end
end
return false
end
Expand Down
12 changes: 11 additions & 1 deletion base/div.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,17 @@ julia> divrem(7,3)
```
"""
divrem(x, y) = divrem(x, y, RoundToZero)
divrem(a, b, r::RoundingMode) = (div(a, b, r), rem(a, b, r))
function divrem(a, b, r::RoundingMode)
if r == RoundToZero
# For compat. Remove in 2.0.
(div(a, b), rem(a, b))
elseif r === RoundDown
# For compat. Remove in 2.0.
(fld(a, b), mod(a, b))
else
(div(a, b, r), rem(a, b, r))
end
end
function divrem(x::Integer, y::Integer, rnd::typeof(RoundNearest))
(q, r) = divrem(x, y)
if x >= 0
Expand Down
33 changes: 21 additions & 12 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -517,20 +517,29 @@ function mktemp(parent::AbstractString=tempdir(); cleanup::Bool=true)
return (filename, Base.open(filename, "r+"))
end

# generate a random string from random bytes
function _rand_string()
nchars = 10
A = Vector{UInt8}(undef, nchars)
windowserror("SystemFunction036 (RtlGenRandom)", 0 == ccall(
(:SystemFunction036, :Advapi32), stdcall, UInt8, (Ptr{Cvoid}, UInt32),
A, sizeof(A)))

slug = Base.StringVector(10)
chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i = 1:nchars
slug[i] = chars[(A[i] % length(chars)) + 1]
end
return name = String(slug)
end

function tempname(parent::AbstractString=tempdir(); cleanup::Bool=true)
isdir(parent) || throw(ArgumentError("$(repr(parent)) is not a directory"))
seed::UInt32 = rand(UInt32)
while true
if (seed & typemax(UInt16)) == 0
seed += 1
end
filename = _win_tempname(parent, seed)
if !ispath(filename)
cleanup && temp_cleanup_later(filename)
return filename
end
seed += 1
end
name = _rand_string()
filename = joinpath(parent, temp_prefix * name)
@assert !ispath(filename)
cleanup && temp_cleanup_later(filename)
return filename
end

else # !windows
Expand Down
33 changes: 9 additions & 24 deletions base/gcutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,20 @@ Module with garbage collection utilities.
"""
module GC

# @enum-like structure
struct CollectionType
x::Int
end
Base.cconvert(::Type{Cint}, collection::CollectionType) = Cint(collection.x)

const Auto = CollectionType(0)
const Full = CollectionType(1)
const Incremental = CollectionType(2)

"""
GC.gc(full::Bool=true)
GC.gc(collection::CollectionType)
GC.gc()
GC.gc(full::Bool)
Perform garbage collection. The argument `full` determines whether a full, but more costly
collection is performed. Otherwise, heuristics are used to determine which type of
collection is needed. For exact control, pass an argument of type `CollectionType`.
Perform garbage collection. The argument `full` determines the kind of collection: A full
collection scans all objects, while an incremental collection only scans so-called young
objects and is much quicker. If called without an argument, heuristics are used to determine
which type of collection is needed.
!!! warning
Excessive use will likely lead to poor performance.
"""
gc(full::Bool=true) = ccall(:jl_gc_collect, Cvoid, (Cint,), full)
gc(collection::CollectionType) = ccall(:jl_gc_collect, Cvoid, (Cint,), collection)
gc() = ccall(:jl_gc_collect, Cvoid, (Cint,), 0)
gc(full::Bool) = ccall(:jl_gc_collect, Cvoid, (Cint,), full ? 1 : 2)

"""
GC.enable(on::Bool)
Expand Down Expand Up @@ -99,13 +90,7 @@ macro preserve(args...)
for x in syms
isa(x, Symbol) || error("Preserved variable must be a symbol")
end
s, r = gensym(), gensym()
esc(quote
$s = $(Expr(:gc_preserve_begin, syms...))
$r = $(args[end])
$(Expr(:gc_preserve_end, s))
$r
end)
esc(Expr(:gc_preserve, args[end], syms...))
end

"""
Expand Down
4 changes: 2 additions & 2 deletions base/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ julia> signed(unsigned(-2))
-2
```
"""
unsigned(x) = convert(Unsigned, x)
unsigned(x) = x % typeof(convert(Unsigned, zero(x)))
unsigned(x::BitSigned) = reinterpret(typeof(convert(Unsigned, zero(x))), x)

"""
Expand All @@ -164,7 +164,7 @@ unsigned(x::BitSigned) = reinterpret(typeof(convert(Unsigned, zero(x))), x)
Convert a number to a signed integer. If the argument is unsigned, it is reinterpreted as
signed without checking for overflow.
"""
signed(x) = convert(Signed, x)
signed(x) = x % typeof(convert(Signed, zero(x)))
signed(x::BitUnsigned) = reinterpret(typeof(convert(Signed, zero(x))), x)

div(x::BitSigned, y::Unsigned) = flipsign(signed(div(unsigned(abs(x)), y)), x)
Expand Down
18 changes: 11 additions & 7 deletions base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ end

gcd(a::Union{Integer,Rational}) = a
lcm(a::Union{Integer,Rational}) = a
gcd(a::Union{Integer,Rational}, b::Union{Integer,Rational}) = gcd(promote(a,b)...)
lcm(a::Union{Integer,Rational}, b::Union{Integer,Rational}) = lcm(promote(a,b)...)
gcd(a::Union{Integer,Rational}, b::Union{Integer,Rational}...) = gcd(a, gcd(b...))
lcm(a::Union{Integer,Rational}, b::Union{Integer,Rational}...) = lcm(a, lcm(b...))
gcd(a::Real, b::Real) = gcd(promote(a,b)...)
lcm(a::Real, b::Real) = lcm(promote(a,b)...)
gcd(a::Real, b::Real, c::Real...) = gcd(a, gcd(b, c...))
lcm(a::Real, b::Real, c::Real...) = lcm(a, lcm(b, c...))
gcd(a::T, b::T) where T<:Real = throw(MethodError(gcd, (a,b)))
lcm(a::T, b::T) where T<:Real = throw(MethodError(lcm, (a,b)))

lcm(abc::AbstractArray{<:Union{Integer,Rational}}) = reduce(lcm, abc; init=one(eltype(abc)))
gcd(abc::AbstractArray{<:Real}) = reduce(gcd, abc; init=zero(eltype(abc)))
lcm(abc::AbstractArray{<:Real}) = reduce(lcm, abc; init=one(eltype(abc)))

function gcd(abc::AbstractArray{<:Union{Integer,Rational}})
function gcd(abc::AbstractArray{<:Integer})
a = zero(eltype(abc))
for b in abc
a = gcd(a,b)
Expand Down Expand Up @@ -146,7 +149,8 @@ function gcdx(a::T, b::T) where T<:Integer
end
a < 0 ? (-a, -s0, -t0) : (a, s0, t0)
end
gcdx(a::Union{Integer,Rational}, b::Union{Integer,Rational}) = gcdx(promote(a,b)...)
gcdx(a::Real, b::Real) = gcdx(promote(a,b)...)
gcdx(a::T, b::T) where T<:Real = throw(MethodError(gcdx, (a,b)))

# multiplicative inverse of n mod m, error if none

Expand Down
1 change: 1 addition & 0 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ julia> hypot(3, 4im)
hypot(x::Number, y::Number) = hypot(promote(x, y)...)
hypot(x::Complex, y::Complex) = hypot(abs(x), abs(y))
hypot(x::T, y::T) where {T<:Real} = hypot(float(x), float(y))
hypot(x::T, y::T) where {T<:Number} = (z = y/x; abs(x) * sqrt(one(z) + z*z))
function hypot(x::T, y::T) where T<:AbstractFloat
#Return Inf if either or both imputs is Inf (Compliance with IEEE754)
if isinf(x) || isinf(y)
Expand Down
3 changes: 2 additions & 1 deletion base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ end

const empty_sym = Symbol("")

function kwarg_decl(m::Method)
# NOTE: second argument is deprecated and is no longer used
function kwarg_decl(m::Method, kwtype = nothing)
mt = get_methodtable(m)
if isdefined(mt, :kwsorter)
kwtype = typeof(mt.kwsorter)
Expand Down
3 changes: 3 additions & 0 deletions base/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ function splitext(path::String)
a*m.captures[1], String(m.captures[2])
end

# NOTE: deprecated in 1.4
pathsep() = path_separator

"""
splitpath(path::AbstractString) -> Vector{String}
Expand Down
2 changes: 1 addition & 1 deletion base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct FlatteningRF{T}
end

@inline function (op::FlatteningRF)(acc, x)
op′, itr′ = _xfadjoint(BottomRF(op.rf), x)
op′, itr′ = _xfadjoint(op.rf, x)
return _foldl_impl(op′, acc, itr′)
end

Expand Down
8 changes: 4 additions & 4 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -868,14 +868,14 @@ end
Return the method table for `f`.
If `types` is specified, return an array of methods whose types match.
If `module` is specified, return an array of methods defined in this module.
A list of modules can also be specified as an array or tuple.
If `module` is specified, return an array of methods defined in that module.
A list of modules can also be specified as an array.
!!! compat "Julia 1.4"
At least Julia 1.4 is required for specifying a module.
"""
function methods(@nospecialize(f), @nospecialize(t),
@nospecialize(mod::Union{Module,AbstractArray{Module},Tuple{Vararg{Module}},Nothing}=nothing))
@nospecialize(mod::Union{Module,AbstractArray{Module},Nothing}=nothing))
if mod isa Module
mod = (mod,)
end
Expand All @@ -900,7 +900,7 @@ function methods_including_ambiguous(@nospecialize(f), @nospecialize(t))
end

function methods(@nospecialize(f),
@nospecialize(mod::Union{Module,AbstractArray{Module},Tuple{Vararg{Module}},Nothing}=nothing))
@nospecialize(mod::Union{Module,AbstractArray{Module},Nothing}=nothing))
# return all matches
return methods(f, Tuple{Vararg{Any}}, mod)
end
Expand Down
6 changes: 6 additions & 0 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ end

# total number of bytes allocated so far
gc_bytes(b::Ref{Int64}) = ccall(:jl_gc_get_total_bytes, Cvoid, (Ptr{Int64},), b)
# NOTE: gc_bytes() is deprecated
function gc_bytes()
b = Ref{Int64}()
gc_bytes(b)
b[]
end

"""
@allocated
Expand Down
4 changes: 2 additions & 2 deletions deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PCRE_BB_REL = 0
DSFMT_VER = 2.2.3
DSFMT_BB_REL = 0
OPENBLAS_VER = 0.3.5
OPENBLAS_BB_REL = 2
OPENBLAS_BB_REL = 0
LAPACK_VER = 3.5.0
SUITESPARSE_VER = 5.4.0
SUITESPARSE_BB_REL = 2
Expand Down Expand Up @@ -40,4 +40,4 @@ P7ZIP_BB_REL = 1
# Specify the version of the Mozilla CA Certificate Store to obtain.
# The versions of cacert.pem are identified by the date (YYYY-MM-DD) of their changes.
# See https://curl.haxx.se/docs/caextract.html for more details.
MOZILLA_CACERT_VERSION := 2019-10-16
MOZILLA_CACERT_VERSION := 2020-01-01
9 changes: 7 additions & 2 deletions deps/blas.mk
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-skylakexdgemm.patch-applied: $(BUILDDIR
patch -p1 -f < $(SRCDIR)/patches/openblas-skylakexdgemm.patch
echo 1 > $@

$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-skylakexdgemm.patch-applied
$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-winexit.patch-applied: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/source-extracted
cd $(BUILDDIR)/$(OPENBLAS_SRC_DIR) && \
patch -p1 -f < $(SRCDIR)/patches/openblas-winexit.patch
echo 1 > $@

$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-skylakexdgemm.patch-applied $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-winexit.patch-applied
echo 1 > $@

$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-compiled: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured
Expand Down Expand Up @@ -204,7 +209,7 @@ check-lapack: $(BUILDDIR)/lapack-$(LAPACK_VER)/build-checked
else # USE_BINARYBUILDER_OPENBLAS


OPENBLAS_BB_URL_BASE := https://github.com/JuliaPackaging/Yggdrasil/releases/download/OpenBLAS-v$(OPENBLAS_VER)-$(OPENBLAS_BB_REL)
OPENBLAS_BB_URL_BASE := https://github.com/JuliaBinaryWrappers/OpenBLAS_jll.jl/releases/download/OpenBLAS-v$(OPENBLAS_VER)+$(OPENBLAS_BB_REL)
OPENBLAS_BB_NAME := OpenBLAS.v$(OPENBLAS_VER)

$(eval $(call bb-install,openblas,OPENBLAS,true))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9bbf83fce2f15f717101ec7d0df2fa4f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
667f9036b2ae1e16feb2c59192561017d14b843f1f967e9a150f2b3190f3d14624a4bcab322fc4ebc9ba0281d721c1ecd326fc1cf663ed3b59f57a82ea6834fd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1f4a939afe0bcb144e588b62be0b3d37
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d203ee0b090d88fb9cf0c7639c638c6d57794c51c40489fd27c7d8bebdf5313882ba0c38860c2dd8c9ae3f8aad0731618e5fa03981db74ef2500a6b9140c6680
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2583fe7faf43fe4b24dfd8e3552bb565
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
008ca412e9a01cb654d363be902b5b608b23831daa93190a3a1193176d620bd0b148fcd0dfcbc1ebe33fb966f4924372dc198f69d3ac5ec255ec56b2d3c92bb8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
996600c776b5beb7a3546dfd2d827891
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4f1356ba08aaeafe454c8c8d53bd4706bc32cd424c047b51d46a1b2b4a645a98b8f20adee7e30a255182bdc36e0b26b30a02fd9308aae18e0c08b34c419fdc53
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7e521282dea43200f63f41761af7395c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e00d07c97934b5df947ea0d503a95d5e075c8c18373199515304b3370db96685c6e0b0503e8631a91ff7487a9b69f92163cd7899480231a33b59a2ab58c13950
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
01607bf69c96015b04a48dee37d1c294
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c90771eaec17085115eef4de826689ba1910919b1469d694c01e0dba7909242a4fc49df788efb798349c5fa275156d63b4b544fb6e1fe559e82bcc2674006e73
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ada3082418bd4b41b876db90e731b8f7
Loading

0 comments on commit 1c977b0

Please sign in to comment.