Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Backports for Julia 1.5-beta-1 #35846

Merged
merged 17 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Compiler/Runtime improvements
Code that requires assumptions about object layout and addresses (usually for
interoperability with C or other languages) might need to be updated; for
example any object that needs a stable address should be a `mutable struct`.
As a result, Array `view`s no longer allocate ([#34126]).

Command-line option changes
---------------------------
Expand Down
14 changes: 13 additions & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ Copy `N` elements from collection `src` starting at offset `so`, to array `dest`
offset `do`. Return `dest`.
"""
function copyto!(dest::Array, doffs::Integer, src::Array, soffs::Integer, n::Integer)
return _copyto_impl!(dest, doffs, src, soffs, n)
end

# this is only needed to avoid possible ambiguities with methods added in some packages
function copyto!(dest::Array{T}, doffs::Integer, src::Array{T}, soffs::Integer, n::Integer) where T
return _copyto_impl!(dest, doffs, src, soffs, n)
end

function _copyto_impl!(dest::Array, doffs::Integer, src::Array, soffs::Integer, n::Integer)
n == 0 && return dest
n > 0 || _throw_argerror()
if soffs < 1 || doffs < 1 || soffs+n-1 > length(src) || doffs+n-1 > length(dest)
Expand All @@ -339,6 +348,9 @@ end

copyto!(dest::Array, src::Array) = copyto!(dest, 1, src, 1, length(src))

# also to avoid ambiguities in packages
copyto!(dest::Array{T}, src::Array{T}) where {T} = copyto!(dest, 1, src, 1, length(src))

# N.B: The generic definition in multidimensional.jl covers, this, this is just here
# for bootstrapping purposes.
function fill!(dest::Array{T}, x) where T
Expand Down Expand Up @@ -1762,8 +1774,8 @@ CartesianIndex(1, 1)
```
"""
function findnext(testf::Function, A, start)
i = oftype(first(keys(A)), start)
l = last(keys(A))
i = oftype(l, start)
i > l && return nothing
while true
testf(A[i]) && return i
Expand Down
1 change: 1 addition & 0 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ _new(:QuoteNode, :Any)
_new(:SSAValue, :Int)
eval(Core, :(LineNumberNode(l::Int) = $(Expr(:new, :LineNumberNode, :l, nothing))))
eval(Core, :(LineNumberNode(l::Int, @nospecialize(f)) = $(Expr(:new, :LineNumberNode, :l, :f))))
LineNumberNode(l::Int, f::String) = LineNumberNode(l, Symbol(f))
eval(Core, :(GlobalRef(m::Module, s::Symbol) = $(Expr(:new, :GlobalRef, :m, :s))))
eval(Core, :(SlotNumber(n::Int) = $(Expr(:new, :SlotNumber, :n))))
eval(Core, :(TypedSlot(n::Int, @nospecialize(t)) = $(Expr(:new, :TypedSlot, :n, :t))))
Expand Down
2 changes: 1 addition & 1 deletion base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ Create a new entry in the `ImmutableDict` for a `key => value` pair
ImmutableDict
ImmutableDict(KV::Pair{K,V}) where {K,V} = ImmutableDict{K,V}(KV[1], KV[2])
ImmutableDict(t::ImmutableDict{K,V}, KV::Pair) where {K,V} = ImmutableDict{K,V}(t, KV[1], KV[2])
ImmutableDict(KV::Pair, rest::Pair...) = ImmutableDict(ImmutableDict(rest...), KV)
ImmutableDict(KV::Pair, rest::Pair...) = ImmutableDict(ImmutableDict(KV), rest...)

function in(key_value::Pair, dict::ImmutableDict, valcmp=(==))
key, value = key_value
Expand Down
4 changes: 2 additions & 2 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end
"""
evalpoly(x, p)

Evaluate the polynomial ``\\sum_k p[k] x^{k-1}`` for the coefficients `p[1]`, `p[2]`, ...;
Evaluate the polynomial ``\\sum_k x^{k-1} p[k]`` for the coefficients `p[1]`, `p[2]`, ...;
that is, the coefficients are given in ascending order by power of `x`.
Loops are unrolled at compile time if the number of coefficients is statically known, i.e.
when `p` is a `Tuple`.
Expand Down Expand Up @@ -210,7 +210,7 @@ end
"""
@evalpoly(z, c...)

Evaluate the polynomial ``\\sum_k c[k] z^{k-1}`` for the coefficients `c[1]`, `c[2]`, ...;
Evaluate the polynomial ``\\sum_k z^{k-1} c[k]`` for the coefficients `c[1]`, `c[2]`, ...;
that is, the coefficients are given in ascending order by power of `z`. This macro expands
to efficient inline code that uses either Horner's method or, for complex `z`, a more
efficient Goertzel-like algorithm.
Expand Down
22 changes: 13 additions & 9 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,25 +306,29 @@ with reduction `op` over an empty array with element type of `T`.

If not defined, this will throw an `ArgumentError`.
"""
reduce_empty(op, T) = _empty_reduce_error()
reduce_empty(::typeof(+), T) = zero(T)
reduce_empty(op, ::Type{T}) where {T} = _empty_reduce_error()
reduce_empty(::typeof(+), ::Type{Union{}}) = _empty_reduce_error()
reduce_empty(::typeof(+), ::Type{T}) where {T} = zero(T)
reduce_empty(::typeof(+), ::Type{Bool}) = zero(Int)
reduce_empty(::typeof(*), T) = one(T)
reduce_empty(::typeof(*), ::Type{Union{}}) = _empty_reduce_error()
reduce_empty(::typeof(*), ::Type{T}) where {T} = one(T)
reduce_empty(::typeof(*), ::Type{<:AbstractChar}) = ""
reduce_empty(::typeof(&), ::Type{Bool}) = true
reduce_empty(::typeof(|), ::Type{Bool}) = false

reduce_empty(::typeof(add_sum), T) = reduce_empty(+, T)
reduce_empty(::typeof(add_sum), ::Type{Union{}}) = _empty_reduce_error()
reduce_empty(::typeof(add_sum), ::Type{T}) where {T} = reduce_empty(+, T)
reduce_empty(::typeof(add_sum), ::Type{T}) where {T<:SmallSigned} = zero(Int)
reduce_empty(::typeof(add_sum), ::Type{T}) where {T<:SmallUnsigned} = zero(UInt)
reduce_empty(::typeof(mul_prod), T) = reduce_empty(*, T)
reduce_empty(::typeof(mul_prod), ::Type{Union{}}) = _empty_reduce_error()
reduce_empty(::typeof(mul_prod), ::Type{T}) where {T} = reduce_empty(*, T)
reduce_empty(::typeof(mul_prod), ::Type{T}) where {T<:SmallSigned} = one(Int)
reduce_empty(::typeof(mul_prod), ::Type{T}) where {T<:SmallUnsigned} = one(UInt)

reduce_empty(op::BottomRF, T) = reduce_empty(op.rf, T)
reduce_empty(op::MappingRF, T) = mapreduce_empty(op.f, op.rf, T)
reduce_empty(op::FilteringRF, T) = reduce_empty(op.rf, T)
reduce_empty(op::FlipArgs, T) = reduce_empty(op.f, T)
reduce_empty(op::BottomRF, ::Type{T}) where {T} = reduce_empty(op.rf, T)
reduce_empty(op::MappingRF, ::Type{T}) where {T} = mapreduce_empty(op.f, op.rf, T)
reduce_empty(op::FilteringRF, ::Type{T}) where {T} = reduce_empty(op.rf, T)
reduce_empty(op::FlipArgs, ::Type{T}) where {T} = reduce_empty(op.f, T)

"""
Base.mapreduce_empty(f, op, T)
Expand Down
2 changes: 1 addition & 1 deletion base/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ size(V::SubArray) = (@_inline_meta; map(n->Int(unsafe_length(n)), axes(V)))

similar(V::SubArray, T::Type, dims::Dims) = similar(V.parent, T, dims)

sizeof(V::SubArray) = length(V) * sizeof(eltype(V))
sizeof(V::SubArray) = length(V) * elsize(V.parent)

copy(V::SubArray) = V.parent[V.indices...]

Expand Down
1 change: 1 addition & 0 deletions base/weakkeydict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function WeakKeyDict(kv)
end
end

sizehint!(d::WeakKeyDict, newsz) = sizehint!(d.ht, newsz)
empty(d::WeakKeyDict, ::Type{K}, ::Type{V}) where {K, V} = WeakKeyDict{K, V}()

islocked(wkh::WeakKeyDict) = islocked(wkh.lock)
Expand Down
2 changes: 1 addition & 1 deletion deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LIBUV_BB_REL = 0
OBJCONV_VER = 2.49.0
OBJCONV_BB_REL = 0
ZLIB_VER = 1.2.11
ZLIB_BB_REL = 6
ZLIB_BB_REL = 10
P7ZIP_VER = 16.2.0
P7ZIP_BB_REL = 1

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3ef6ca69b7cdef18228ccab2ce20d84f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eb69f2f5abb8b9a3ec7abd52beff2286d7c2b3861b57459d63dc6783c28c64cb034c539d2b1b05f3bd696ae8adae32cc330b540ad111a06005879f00066a05b9
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14b820d6b0c164e36440329304dd8dbb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7160582d061aeeed18d24fe8981a85e02086e2dbe3cda4f3786382351f1764117701a01d5f217b82d9263e0ac63f2caa2ce6ee5ad20dfc6e5cebba6af03b8826

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
51358c64e42d3b8d923451278fc7aa18
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4812a79c1abf7b6301f7d1b4d65116e1add5edcaee574c6797d5c6c75b97fc9557d4e321d69afcf2dc1cd7c86b5f23f26a5cffd4541235e43c3d929498793554
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d967ee51bc241699462b50466208b7a1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b534781b3aa10ed2d5b426c2e4773ebf02aa09dd3b99326b3d74361260459ca4aff8e0638f5bafc2bc7b1c5e9eb27d37815194667ba09bf75360489caac2dc07
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4324accedf22fe4733323f91ec408eca
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e7bc261ef2ff5e1dad9135dd6278365db0865b99b75d4086a27793e8c45276a609556c8145188fdfa9e617f583ac1c8992d02854862453d40849e49c39ae4a2e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6544bd96203abd28b5a9ab4de809cfb3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cec06a2b7a1bd44f69c5281aa4db0f032506598b5d9b2f81716587f07321528aefc8f52c3ad686c16b923715fa13b0d7a0f182d7dacafafe55059346f1ea24cb
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-10.i686-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
760ea40b76d53f6de170f09a17fc3aec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
550e950ddf02598eefa013c47f9c13ded8468fdf871602de85156f2c4654f515a56ba3b8881441144a78453ebed99b9ea4b580ad940b9d587208309b20da385c
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-10.i686-linux-musl.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
390f2326a32f1c5ee44585a49a60ecf9
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
357beb491a420dbbd6640df3ff8bb3e32be9fe0308d4b44c956b1c50f40f08dd6d77118c7ae46a4149e48772e6b545987542e7709d545cc486374710a6bc8cb3
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-10.i686-w64-mingw32.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0b4e00c3d2ef8a4aaf7154c18ada2348
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9bb1f68607b07c8f20f18d839d7b13ca87e45ac57a6c3bffcf27db26c11d99433e08af391939b61c13f49e5df5feddce2ff5d9d962ca0d7e89d850288f563172
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
becb958e9f99b08a152824c8a44454d5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
857225765e3af15463128b7d4aca87c358c34c802fbf7863cdeed06f958b2c3976750c8583bfcf0ef12c106519563248f80a676337d340fddfc005f7cab09b7c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b073327b80d77fcb321aa90ac054f3bc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3e568123255eb2e3fd6b59395ebc72407743f596ead1cc2efaf1f2cbdb88f554ea53cf7caa3f062a8a6695eeb591a6f6ff1304bd0915b148fce4849c36e915e2
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-10.x86_64-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9b387576651cf42d2cba762509603aa0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
31020590c9f122954eb545515adeb3b93894caa7098e6a12b70cbbd71a9e1b71f4d3185d0960f4f2e192fbe74a0d2c944d1cd897c715aa3e7182ea3cfc82a63f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8eb752c5fb3f1f013a91ba84db33f268
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9c4b198cceffc5e3c87e91fa4f9223b973b090f5a343b1ea84425cbb445a7d9a34926ca55e4febae8783fbba3390b3a1aa2bd59b3177335a544c862bd55b8ec5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bffe25dd8fb78bbf881785eef64202d5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2215ee8ebd3415f35a4f488537b2bb525bc8fef74419b2182bb8bc5b2e236fa7fb637c6aaa234e840c94c3940a71441e5a2dc9e7fb5d674372175a30dbb5fa19
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9efba92de9aa49b43822309fcdce046a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c76553c7b79c8f2ed20dcbfbb55ebe06636e238c3ba7028beef84547cf1ee82c2a2a293712c9241e7b60cb5cf6c907eec7046b272a0ef26aed805eae4947a9c6
1 change: 0 additions & 1 deletion deps/checksums/Zlib.v1.2.11-6.aarch64-linux-gnu.tar.gz/md5

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion deps/checksums/Zlib.v1.2.11-6.i686-linux-gnu.tar.gz/md5

This file was deleted.

1 change: 0 additions & 1 deletion deps/checksums/Zlib.v1.2.11-6.i686-linux-gnu.tar.gz/sha512

This file was deleted.

1 change: 0 additions & 1 deletion deps/checksums/Zlib.v1.2.11-6.i686-linux-musl.tar.gz/md5

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion deps/checksums/Zlib.v1.2.11-6.i686-w64-mingw32.tar.gz/md5

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion deps/checksums/Zlib.v1.2.11-6.x86_64-linux-gnu.tar.gz/md5

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion deps/checksums/Zlib.v1.2.11-6.x86_64-linux-musl.tar.gz/md5

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion deps/zlib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $(eval $(call git-external,zlib,ZLIB,,,$(SRCCACHE)))
ifneq ($(USE_BINARYBUILDER_ZLIB), 1)
$(BUILDDIR)/$(ZLIB_SRC_DIR)/build-configured: $(SRCCACHE)/$(ZLIB_SRC_DIR)/source-extracted
mkdir -p $(dir $@)
cd $(dir $@) && $(dir $<)/configure --prefix=$(abspath $(build_prefix)) --libdir=$(abspath $(build_libdir))
cd $(dir $@) && $(CMAKE) -DCMAKE_INSTALL_PREFIX=$(abspath $(build_prefix)) -DCMAKE_BUILD_TYPE=Release -DUNIX=true $(dir $<)
echo 1 > $@

$(BUILDDIR)/$(ZLIB_SRC_DIR)/build-compiled: $(BUILDDIR)/$(ZLIB_SRC_DIR)/build-configured
Expand Down
4 changes: 2 additions & 2 deletions doc/src/manual/distributed-computing.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Multi-process and Distributed Processing
# Multi-processing and Distributed Computing

An implementation of distributed memory parallel computing is provided by module `Distributed`
as part of the standard library shipped with Julia.
Expand Down Expand Up @@ -760,7 +760,7 @@ SharedArray{T,N}(dims::NTuple; init=false, pids=Int[])
which creates an `N`-dimensional shared array of a bits type `T` and size `dims` across the processes specified
by `pids`. Unlike distributed arrays, a shared array is accessible only from those participating
workers specified by the `pids` named argument (and the creating process too, if it is on the
same host).
same host). Note that only elements that are [`isbits`](@ref) are supported in a SharedArray.

If an `init` function, of signature `initfn(S::SharedArray)`, is specified, it is called on all
the participating workers. You can specify that each worker runs the `init` function on a distinct
Expand Down
2 changes: 1 addition & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ static Type *_julia_struct_to_llvm(jl_codegen_params_t *ctx, jl_value_t *jt, jl_
Type *AlignmentType = IntegerType::get(jl_LLVMContext, 8 * al);
unsigned NumATy = fsz / al;
unsigned remainder = fsz % al;
assert(NumATy > 0);
assert(al == 1 || NumATy > 0);
while (NumATy--)
latypes.push_back(AlignmentType);
while (remainder--)
Expand Down
7 changes: 6 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,7 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
*ret = mark_julia_type(ctx, len, false, jl_long_type);
return true;
}
else if (jl_is_datatype(sty) && sty->name == jl_array_typename) {
else if (jl_is_array_type(sty)) {
auto len = emit_arraylen(ctx, obj);
jl_value_t *ety = jl_tparam0(sty);
Value *elsize;
Expand All @@ -2495,6 +2495,11 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
if (isboxed) {
elsize = ConstantInt::get(T_size, sizeof(void*));
}
else if (jl_is_primitivetype(ety)) {
// Primitive types should use the array element size, but
// this can be different from the type's size
elsize = ConstantInt::get(T_size, LLT_ALIGN(elsz, al));
}
else {
elsize = ConstantInt::get(T_size, elsz);
}
Expand Down
24 changes: 24 additions & 0 deletions src/llvm-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <llvm/ADT/Triple.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/Analysis/TargetTransformInfo.h>
#include <llvm/IR/Attributes.h>
#include <llvm/IR/CallSite.h>
#include <llvm/IR/DebugInfo.h>
Expand All @@ -24,6 +25,7 @@
#include <llvm/IR/Module.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/ModuleUtils.h>

#include "julia.h"

Expand Down Expand Up @@ -208,6 +210,28 @@ extern "C" JL_DLLEXPORT void LLVMExtraAddInternalizePassWithExportList(
unwrap(PM)->add(createInternalizePass(PreserveFobj));
}

extern "C" JL_DLLEXPORT void LLVMExtraAppendToUsed(LLVMModuleRef Mod,
LLVMValueRef* Values,
size_t Count) {
SmallVector<GlobalValue *, 1> GlobalValues;
for (auto *Value : makeArrayRef(Values, Count))
GlobalValues.push_back(cast<GlobalValue>(unwrap(Value)));
appendToUsed(*unwrap(Mod), GlobalValues);
}

extern "C" JL_DLLEXPORT void LLVMExtraAppendToCompilerUsed(LLVMModuleRef Mod,
LLVMValueRef* Values,
size_t Count) {
SmallVector<GlobalValue *, 1> GlobalValues;
for (auto *Value : makeArrayRef(Values, Count))
GlobalValues.push_back(cast<GlobalValue>(unwrap(Value)));
appendToCompilerUsed(*unwrap(Mod), GlobalValues);
}

extern "C" JL_DLLEXPORT void LLVMExtraAddGenericAnalysisPasses(LLVMPassManagerRef PM) {
unwrap(PM)->add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
}


// Awaiting D46627

Expand Down
Loading