Codebase list julia / d7d0ee2
New upstream version 1.0.4+dfsg Mo Zhou 5 years ago
71 changed file(s) with 935 addition(s) and 158 deletion(s). Raw diff Collapse all Expand all
3939 - gfortran-5
4040 - os: osx
4141 env: ARCH="x86_64"
42 osx_image: xcode8
42 osx_image: xcode8.3
4343 cache: ccache
4444 branches:
4545 only:
0 1.0.3
0 1.0.4
6666 end
6767
6868 max_values(::Type) = typemax(Int)
69 max_values(T::Type{<:Union{Nothing,BitIntegerSmall}}) = 1 << (8*sizeof(T))
70 max_values(T::Union) = max(max_values(T.a), max_values(T.b))
69 max_values(T::Union{map(X -> Type{X}, BitIntegerSmall_types)...}) = 1 << (8*sizeof(T))
70 # saturated addition to prevent overflow with typemax(Int)
71 max_values(T::Union) = max(max_values(T.a), max_values(T.b), max_values(T.a) + max_values(T.b))
7172 max_values(::Type{Bool}) = 2
73 max_values(::Type{Nothing}) = 1
7274
7375 function union!(s::AbstractSet{T}, itr) where T
7476 haslength(itr) && sizehint!(s, length(s) + length(itr))
433433 io = IOContext(io, :typeinfo => eltype(v), :compact => get(io, :compact, true))
434434 limited = get(io, :limit, false)
435435 if limited && length(v) > 20
436 inds = axes1(v)
437 show_delim_array(io, v, opn, ",", "", false, inds[1], inds[1]+9)
436 axs1 = axes1(v)
437 f, l = first(axs1), last(axs1)
438 show_delim_array(io, v, opn, ",", "", false, f, f+9)
438439 print(io, " … ")
439 show_delim_array(io, v, "", ",", cls, false, inds[end-9], inds[end])
440 show_delim_array(io, v, "", ",", cls, false, l-9, l)
440441 else
441442 show_delim_array(io, v, opn, ",", cls, false)
442443 end
129129 return defssa
130130 end
131131 if isa(def.val, SSAValue)
132 if isa(defssa, OldSSAValue) && !already_inserted(compact, defssa)
132 if is_old(compact, defssa)
133133 defssa = OldSSAValue(def.val.id)
134134 else
135135 defssa = def.val
190190 collect(Iterators.filter(1:length(def.edges)) do n
191191 isassigned(def.values, n) || return false
192192 val = def.values[n]
193 if isa(defssa, OldSSAValue) && isa(val, SSAValue)
193 if is_old(compact, defssa) && isa(val, SSAValue)
194194 val = OldSSAValue(val.id)
195195 end
196196 edge_typ = widenconst(compact_exprtype(compact, val))
200200 for n in possible_predecessors
201201 pred = def.edges[n]
202202 val = def.values[n]
203 if isa(defssa, OldSSAValue) && isa(val, SSAValue)
203 if is_old(compact, defssa) && isa(val, SSAValue)
204204 val = OldSSAValue(val.id)
205205 end
206206 if isa(val, AnySSAValue)
280280 end
281281 if is_tuple_call(compact.ir, def) && isa(field, Int) && 1 <= field < length(def.args)
282282 lifted = def.args[1+field]
283 if isa(leaf, OldSSAValue) && isa(lifted, SSAValue)
283 if is_old(compact, leaf) && isa(lifted, SSAValue)
284284 lifted = OldSSAValue(lifted.id)
285285 end
286286 if isa(lifted, GlobalRef) || isa(lifted, Expr)
319319 compact[leaf] = def
320320 end
321321 lifted = def.args[1+field]
322 if isa(leaf, OldSSAValue) && isa(lifted, SSAValue)
322 if is_old(compact, leaf) && isa(lifted, SSAValue)
323323 lifted = OldSSAValue(lifted.id)
324324 end
325325 if isa(lifted, GlobalRef) || isa(lifted, Expr)
338338 # N.B.: This can be a bit dangerous because it can lead to
339339 # infinite loops if we accidentally insert a node just ahead
340340 # of where we are
341 if isa(leaf, OldSSAValue) && (isa(field, Int) || isa(field, Symbol))
341 if is_old(compact, leaf) && (isa(field, Int) || isa(field, Symbol))
342342 (isa(typ, DataType) && (!typ.abstract)) || return nothing
343343 @assert !typ.mutable
344344 # If there's the potential for an undefref error on access, we cannot insert a getfield
424424 need_argupdate::Bool
425425 end
426426
427 function is_old(compact, @nospecialize(old_node_ssa))
428 isa(old_node_ssa, OldSSAValue) &&
429 !is_pending(compact, old_node_ssa) &&
430 !already_inserted(compact, old_node_ssa)
431 end
432
427433 function perform_lifting!(compact::IncrementalCompact,
428434 visited_phinodes::Vector{Any}, @nospecialize(cache_key),
429435 lifting_cache::IdDict{Pair{AnySSAValue, Any}, AnySSAValue},
454460 isassigned(old_node.values, i) || continue
455461 val = old_node.values[i]
456462 orig_val = val
457 if isa(old_node_ssa, OldSSAValue) && !is_pending(compact, old_node_ssa) && !already_inserted(compact, old_node_ssa) && isa(val, SSAValue)
463 if is_old(compact, old_node_ssa) && isa(val, SSAValue)
458464 val = OldSSAValue(val.id)
459465 end
460466 if isa(val, Union{NewSSAValue, SSAValue, OldSSAValue})
687693 compact[idx] = val === nothing ? nothing : val.x
688694 end
689695
690 # Copy the use count, `finish` may modify it and for our predicate
691 # below we need it consistent with the state of the IR here.
696
697 non_dce_finish!(compact)
698 # Copy the use count, `simple_dce!` may modify it and for our predicate
699 # below we need it consistent with the state of the IR here (after tracking
700 # phi node arguments, but before dce).
692701 used_ssas = copy(compact.used_ssas)
693 ir = finish(compact)
702 simple_dce!(compact)
703 ir = complete(compact)
694704 # Now go through any mutable structs and see which ones we can eliminate
695705 for (idx, (intermediaries, defuse)) in defuses
696706 intermediaries = collect(intermediaries)
2626 """
2727 deepcopy(x) = deepcopy_internal(x, IdDict())::typeof(x)
2828
29 deepcopy_internal(x::Union{Symbol,Core.MethodInstance,Method,GlobalRef,DataType,Union,Task},
29 deepcopy_internal(x::Union{Symbol,Core.MethodInstance,Method,GlobalRef,DataType,Union,UnionAll,Task},
3030 stackdict::IdDict) = x
3131 deepcopy_internal(x::Tuple, stackdict::IdDict) =
3232 ntuple(i->deepcopy_internal(x[i], stackdict), length(x))
10931093
10941094 @inline peek(s::Stateful, sentinel=nothing) = s.nextvalstate !== nothing ? s.nextvalstate[1] : sentinel
10951095 @inline iterate(s::Stateful, state=nothing) = s.nextvalstate === nothing ? nothing : (popfirst!(s), nothing)
1096 IteratorSize(::Type{Stateful{VS,T}} where VS) where {T} =
1097 isa(IteratorSize(T), SizeUnknown) ? SizeUnknown() : HasLength()
1096 IteratorSize(::Type{Stateful{T,VS}}) where {T,VS} = IteratorSize(T) isa HasShape ? HasLength() : IteratorSize(T)
10981097 eltype(::Type{Stateful{T, VS}} where VS) where {T} = eltype(T)
1099 IteratorEltype(::Type{Stateful{VS,T}} where VS) where {T} = IteratorEltype(T)
1098 IteratorEltype(::Type{Stateful{T,VS}}) where {T,VS} = IteratorEltype(T)
11001099 length(s::Stateful) = length(s.itr) - s.taken
11011100
11021101 end
308308 end
309309
310310 if i₊ == 0 # purely real or imaginary value
311 if iᵢ > 0 # purely imaginary
311 if iᵢ > i && !(iᵢ == i+1 && s[i] in ('+','-')) # purely imaginary (not "±inf")
312312 x = tryparse_internal(T, s, i, iᵢ-1, raise)
313313 x === nothing && return nothing
314314 return Complex{T}(zero(x),x)
607607 @_inline_meta
608608 ret = convert(T, first(v) + (i - 1)*step_hp(v))
609609 ok = ifelse(step(v) > zero(step(v)),
610 (ret <= v.stop) & (ret >= v.start),
611 (ret <= v.start) & (ret >= v.stop))
610 (ret <= last(v)) & (ret >= first(v)),
611 (ret <= first(v)) & (ret >= last(v)))
612612 @boundscheck ((i > 0) & ok) || throw_boundserror(v, i)
613613 ret
614614 end
3232 isbitstype(T) || throwbits(S, T, T)
3333 isbitstype(S) || throwbits(S, T, S)
3434 (N != 0 || sizeof(T) == sizeof(S)) || throwsize0(S, T)
35 ax1 = axes(a)[1]
3635 if N != 0 && sizeof(S) != sizeof(T)
36 ax1 = axes(a)[1]
3737 dim = length(ax1)
3838 rem(dim*sizeof(S),sizeof(T)) == 0 || thrownonint(S, T, dim)
3939 first(ax1) == 1 || throwaxes1(S, T, ax1)
6767
6868 parent(a::ReinterpretArray) = a.parent
6969 dataids(a::ReinterpretArray) = dataids(a.parent)
70 unaliascopy(a::ReinterpretArray{T}) where {T} = reinterpret(T, unaliascopy(a.parent))
7071
7172 function size(a::ReinterpretArray{T,N,S} where {N}) where {T,S}
7273 psize = size(a.parent)
7374 size1 = div(psize[1]*sizeof(S), sizeof(T))
7475 tuple(size1, tail(psize)...)
7576 end
77 size(a::ReinterpretArray{T,0}) where {T} = ()
7678
7779 function axes(a::ReinterpretArray{T,N,S} where {N}) where {T,S}
7880 paxs = axes(a.parent)
8082 size1 = div(l*sizeof(S), sizeof(T))
8183 tuple(oftype(paxs[1], f:f+size1-1), tail(paxs)...)
8284 end
85 axes(a::ReinterpretArray{T,0}) where {T} = ()
8386
8487 elsize(::Type{<:ReinterpretArray{T}}) where {T} = sizeof(T)
8588 unsafe_convert(::Type{Ptr{T}}, a::ReinterpretArray{T,N,S} where N) where {T,S} = Ptr{T}(unsafe_convert(Ptr{S},a.parent))
9595 ```
9696 """
9797 function chop(s::AbstractString; head::Integer = 0, tail::Integer = 1)
98 if isempty(s)
99 return SubString(s)
100 end
98101 SubString(s, nextind(s, firstindex(s), head), prevind(s, lastindex(s), tail))
99102 end
100103
Binary diff not shown
66 UNWIND_VER = 1.1-julia2
77 OSXUNWIND_VER = 0.0.5
88 GMP_VER = 6.1.2
9 MPFR_VER = 4.0.1
9 MPFR_VER = 4.0.2
1010 PATCHELF_VER = 0.9
1111 MBEDTLS_VER = 2.6.0
1212 CURL_VER = 7.56.0
1414 # Specify the version of the Mozilla CA Certificate Store to obtain.
1515 # The versions of cacert.pem are identified by the date (YYYY-MM-DD) of their changes.
1616 # See https://curl.haxx.se/docs/caextract.html for more details.
17 MOZILLA_CACERT_VERSION := 2018-06-20
17 MOZILLA_CACERT_VERSION := 2019-01-23
0 95022a2aee8bca4b8e1ce65b5e5840209cd7adb7d048a647c9501e15e0ebd37fb4e4a95e707a5ec001893789ae841e3300a615f8e21a711694fc288777eed726
+0
-1
deps/checksums/Pkg-93b6d6de857dc88e665d2c64397852ab9701ba24.tar.gz/md5 less more
0 498ed1792ccd8e3a895edf290d8066ca
+0
-1
deps/checksums/Pkg-93b6d6de857dc88e665d2c64397852ab9701ba24.tar.gz/sha512 less more
0 83143d69e27da5fa58e5fa1ceab41aff7af242eea5399d4512c381d12fd90c7a3106db2a84af1f9a33c5bb917e7f05208310f34fd3b182595b581dc8070e3491
0 fccbe6cec7a76e3351ad32e305184787
0 01faebab60b49a30736e0c88b713999f48c99b425889f7df9bbb80eb91367a6f26f20befdf8ac72b8d77659b143b7b37f91ad7dac5fde37c1d621fc663003687
0 ae4c798ae5c13ad1574646896665ccd1f7d91e64573a23662ce7016b00109c1c351013856c25bf12284d9c3996ca3b828506825e50fcb059969adc02a96c06f8
+0
-1
deps/checksums/libssh2-30e9c1347e3b8baa2951db612f05e6d87fc8e2f2.tar.gz/md5 less more
0 d251ef0efecff323b6f570cc737d3411
+0
-1
deps/checksums/libssh2-30e9c1347e3b8baa2951db612f05e6d87fc8e2f2.tar.gz/sha512 less more
0 ae7535cf8f70e7c837e80365cd9ee7c4040d45e952871a3e5c8f1b71bd8eb2d96babb07fa4c5d66a83bb45960728ef8dbba30ab9a6387a68cf815a84cdae8795
+0
-1
deps/checksums/mpfr-4.0.1.tar.bz2/md5 less more
0 8c21d8ac7460493b2b9f3ef3cc610454
+0
-1
deps/checksums/mpfr-4.0.1.tar.bz2/sha512 less more
0 c1674fc0a5edcde188bdf7d6d14063cfb4f1259b9eaf39d0081f7176e9921ca0af1b12b7aba1a9560d9f2d5f37329d22bc7b82f13421d91d83114b439bc60dcc
0 6d8a8bb46fe09ff44e21cdbf84f5cdac
0 18bb3a87123d02b7537bc298d41bdbb33e58b8c196cc4040578e3b470e86c6c89e1bd8ab8b3919d106fe5b86922ef8999dc1aba7c521ee90a69f690be288a30d
2020 cd $(dir $@) && patch < $(SRCDIR)/patches/gmp-exception.patch
2121 echo 1 > $@
2222
23 $(BUILDDIR)/gmp-$(GMP_VER)/build-configured: $(SRCCACHE)/gmp-$(GMP_VER)/source-extracted $(SRCCACHE)/gmp-$(GMP_VER)/build-patched
23 $(SRCCACHE)/gmp-$(GMP_VER)/gmp-config-ldflags.patch-applied: | $(SRCCACHE)/gmp-$(GMP_VER)/build-patched
24 cd $(dir $@) && patch -p1 < $(SRCDIR)/patches/gmp-config-ldflags.patch
25 echo 1 > $@
26
27 $(BUILDDIR)/gmp-$(GMP_VER)/build-configured: $(SRCCACHE)/gmp-$(GMP_VER)/gmp-config-ldflags.patch-applied
28
29 $(BUILDDIR)/gmp-$(GMP_VER)/build-configured: $(SRCCACHE)/gmp-$(GMP_VER)/source-extracted
2430 mkdir -p $(dir $@)
2531 cd $(dir $@) && \
2632 $(dir $<)/configure $(CONFIGURE_COMMON) F77= --enable-shared --disable-static $(GMP_CONFIGURE_OPTS)
0 LIBSSH2_BRANCH=libssh2-1.8.0
1 LIBSSH2_SHA1=30e9c1347e3b8baa2951db612f05e6d87fc8e2f2
0 LIBSSH2_BRANCH=libssh2-1.8.2
1 LIBSSH2_SHA1=02ecf17a6d5f9837699e8fb3aad0c804caa67eeb
6464 LLVM_CPPFLAGS += $(CPPFLAGS)
6565 LLVM_LDFLAGS += $(LDFLAGS)
6666 LLVM_CMAKE += -DLLVM_TARGETS_TO_BUILD:STRING="$(LLVM_TARGETS)" -DCMAKE_BUILD_TYPE="$(LLVM_CMAKE_BUILDTYPE)"
67 LLVM_CMAKE += -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBXML2=OFF
67 LLVM_CMAKE += -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_HOST_TRIPLE="$(or $(XC_HOST),$(BUILD_MACHINE))"
6868 ifeq ($(USE_POLLY_ACC),1)
6969 LLVM_CMAKE += -DPOLLY_ENABLE_GPGPU_CODEGEN=ON
7070 endif
0 --- gmp-6.1.2/configure 2019-03-25 17:58:41.928471374 -0400
1 +++ gmp-6.1.2-LDFLAGS/configure 2019-03-26 13:08:07.756316866 -0400
2 @@ -5880,7 +5880,7 @@ if test "$gmp_prog_cc_works" = yes; then
3 int main () { return 0; }
4 EOF
5 echo "Test compile: " >&5
6 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
7 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
8 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
9 (eval $gmp_compile) 2>&5
10 ac_status=$?
11 @@ -5934,7 +5934,7 @@ void *f() { return g(); }
12 int main () { return 0; }
13 EOF
14 echo "Test compile: function pointer return" >&5
15 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
16 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
17 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
18 (eval $gmp_compile) 2>&5
19 ac_status=$?
20 @@ -5990,7 +5990,7 @@ int cmov () { return (n >= 0 ? n : 0); }
21 int main () { return 0; }
22 EOF
23 echo "Test compile: cmov instruction" >&5
24 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
25 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
26 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
27 (eval $gmp_compile) 2>&5
28 ac_status=$?
29 @@ -6047,7 +6047,7 @@ unsigned long gcc303 () { return (unsign
30 int main () { return 0; }
31 EOF
32 echo "Test compile: double -> ulong conversion" >&5
33 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
34 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
35 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
36 (eval $gmp_compile) 2>&5
37 ac_status=$?
38 @@ -6102,7 +6102,7 @@ unsigned long fneg () { return -fneg_dat
39 int main () { return 0; }
40 EOF
41 echo "Test compile: double negation" >&5
42 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
43 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
44 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
45 (eval $gmp_compile) 2>&5
46 ac_status=$?
47 @@ -6158,7 +6158,7 @@ float ftod () { return (float) ftod_data
48 int main () { return 0; }
49 EOF
50 echo "Test compile: double -> float conversion" >&5
51 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
52 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
53 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
54 (eval $gmp_compile) 2>&5
55 ac_status=$?
56 @@ -6243,7 +6243,7 @@ param_init ()
57 int main () { return 0; }
58 EOF
59 echo "Test compile: gnupro alpha ev6 char spilling" >&5
60 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
61 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
62 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
63 (eval $gmp_compile) 2>&5
64 ac_status=$?
65 @@ -6294,7 +6294,7 @@ if test "$gmp_prog_cc_works" = yes; then
66 int k; int foo () { __builtin_alloca (k); }
67 EOF
68 echo "Test compile: __builtin_alloca availability" >&5
69 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
70 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
71 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
72 (eval $gmp_compile) 2>&5
73 ac_status=$?
74 @@ -6340,7 +6340,7 @@ int foo ()
75 int main () { return 0; }
76 EOF
77 echo "Test compile: alloca array" >&5
78 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
79 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
80 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
81 (eval $gmp_compile) 2>&5
82 ac_status=$?
83 @@ -6418,7 +6418,7 @@ int f ()
84 int main () { return 0; }
85 EOF
86 echo "Test compile: abs int -> double conversion" >&5
87 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
88 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
89 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
90 (eval $gmp_compile) 2>&5
91 ac_status=$?
92 @@ -6483,7 +6483,7 @@ int dummy;
93 int main () { return 0; }
94 EOF
95 echo "Test compile: long long reliability test 1" >&5
96 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
97 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
98 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
99 (eval $gmp_compile) 2>&5
100 ac_status=$?
101 @@ -6544,7 +6544,7 @@ int dummy;
102 int main () { return 0; }
103 EOF
104 echo "Test compile: long long reliability test 2" >&5
105 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
106 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
107 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
108 (eval $gmp_compile) 2>&5
109 ac_status=$?
110 @@ -6605,7 +6605,7 @@ int dummy;
111 int main () { return 0; }
112 EOF
113 echo "Test compile: freebsd hacked gcc" >&5
114 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
115 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
116 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
117 (eval $gmp_compile) 2>&5
118 ac_status=$?
119 @@ -6704,7 +6704,7 @@ main ()
120
121 EOF
122 echo "Test compile: mpn_lshift_com optimization" >&5
123 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
124 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
125 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
126 (eval $gmp_compile) 2>&5
127 ac_status=$?
128 @@ -6813,7 +6813,7 @@ main ()
129
130 EOF
131 echo "Test compile: mpn_lshift_com optimization 2" >&5
132 - gmp_compile="$cc $cflags $cppflags conftest.c >&5"
133 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.c >&5"
134 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
135 (eval $gmp_compile) 2>&5
136 ac_status=$?
137 @@ -7325,7 +7325,7 @@ _main:
138 xorl %eax, %eax
139 ret
140 EOF
141 - gmp_compile="$cc $cflags $cppflags conftest.s -o conftest >&5"
142 + gmp_compile="$cc $cflags $cppflags $LDFLAGS conftest.s -o conftest >&5"
143 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
144 (eval $gmp_compile) 2>&5
145 ac_status=$?
146 @@ -7390,7 +7390,7 @@ $as_echo_n "checking compiler $cc $cflag
147 cat >conftest.c <<EOF
148 int main () { return 0; }
149 EOF
150 - gmp_compile="$cc $cflags -no-cpp-precomp conftest.c >conftest.out 2>&1"
151 + gmp_compile="$cc $cflags $LDFLAGS -no-cpp-precomp conftest.c >conftest.out 2>&1"
152 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
153 (eval $gmp_compile) 2>&5
154 ac_status=$?
155 @@ -7498,7 +7498,7 @@ if test "$gmp_prog_cc_works" = yes; then
156 int main () { return 0; }
157 EOF
158 echo "Test compile: " >&5
159 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
160 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
161 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
162 (eval $gmp_compile) 2>&5
163 ac_status=$?
164 @@ -7552,7 +7552,7 @@ void *f() { return g(); }
165 int main () { return 0; }
166 EOF
167 echo "Test compile: function pointer return" >&5
168 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
169 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
170 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
171 (eval $gmp_compile) 2>&5
172 ac_status=$?
173 @@ -7608,7 +7608,7 @@ int cmov () { return (n >= 0 ? n : 0); }
174 int main () { return 0; }
175 EOF
176 echo "Test compile: cmov instruction" >&5
177 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
178 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
179 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
180 (eval $gmp_compile) 2>&5
181 ac_status=$?
182 @@ -7665,7 +7665,7 @@ unsigned long gcc303 () { return (unsign
183 int main () { return 0; }
184 EOF
185 echo "Test compile: double -> ulong conversion" >&5
186 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
187 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
188 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
189 (eval $gmp_compile) 2>&5
190 ac_status=$?
191 @@ -7720,7 +7720,7 @@ unsigned long fneg () { return -fneg_dat
192 int main () { return 0; }
193 EOF
194 echo "Test compile: double negation" >&5
195 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
196 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
197 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
198 (eval $gmp_compile) 2>&5
199 ac_status=$?
200 @@ -7776,7 +7776,7 @@ float ftod () { return (float) ftod_data
201 int main () { return 0; }
202 EOF
203 echo "Test compile: double -> float conversion" >&5
204 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
205 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
206 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
207 (eval $gmp_compile) 2>&5
208 ac_status=$?
209 @@ -7861,7 +7861,7 @@ param_init ()
210 int main () { return 0; }
211 EOF
212 echo "Test compile: gnupro alpha ev6 char spilling" >&5
213 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
214 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
215 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
216 (eval $gmp_compile) 2>&5
217 ac_status=$?
218 @@ -7912,7 +7912,7 @@ if test "$gmp_prog_cc_works" = yes; then
219 int k; int foo () { __builtin_alloca (k); }
220 EOF
221 echo "Test compile: __builtin_alloca availability" >&5
222 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
223 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
224 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
225 (eval $gmp_compile) 2>&5
226 ac_status=$?
227 @@ -7958,7 +7958,7 @@ int foo ()
228 int main () { return 0; }
229 EOF
230 echo "Test compile: alloca array" >&5
231 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
232 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
233 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
234 (eval $gmp_compile) 2>&5
235 ac_status=$?
236 @@ -8036,7 +8036,7 @@ int f ()
237 int main () { return 0; }
238 EOF
239 echo "Test compile: abs int -> double conversion" >&5
240 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
241 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
242 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
243 (eval $gmp_compile) 2>&5
244 ac_status=$?
245 @@ -8101,7 +8101,7 @@ int dummy;
246 int main () { return 0; }
247 EOF
248 echo "Test compile: long long reliability test 1" >&5
249 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
250 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
251 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
252 (eval $gmp_compile) 2>&5
253 ac_status=$?
254 @@ -8162,7 +8162,7 @@ int dummy;
255 int main () { return 0; }
256 EOF
257 echo "Test compile: long long reliability test 2" >&5
258 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
259 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
260 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
261 (eval $gmp_compile) 2>&5
262 ac_status=$?
263 @@ -8223,7 +8223,7 @@ int dummy;
264 int main () { return 0; }
265 EOF
266 echo "Test compile: freebsd hacked gcc" >&5
267 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
268 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
269 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
270 (eval $gmp_compile) 2>&5
271 ac_status=$?
272 @@ -8322,7 +8322,7 @@ main ()
273
274 EOF
275 echo "Test compile: mpn_lshift_com optimization" >&5
276 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
277 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
278 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
279 (eval $gmp_compile) 2>&5
280 ac_status=$?
281 @@ -8431,7 +8431,7 @@ main ()
282
283 EOF
284 echo "Test compile: mpn_lshift_com optimization 2" >&5
285 - gmp_compile="$cc $cflags $cppflags $flag conftest.c >&5"
286 + gmp_compile="$cc $cflags $cppflags $flag $LDFLAGS conftest.c >&5"
287 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
288 (eval $gmp_compile) 2>&5
289 ac_status=$?
290 @@ -9987,7 +9987,7 @@ main ()
291 return 0;
292 }
293 EOF
294 -gmp_compile="$CC_FOR_BUILD conftest.c"
295 +gmp_compile="$CC_FOR_BUILD $LDFLAGS conftest.c"
296 cc_for_build_works=no
297 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
298 (eval $gmp_compile) 2>&5
299 @@ -10019,7 +10019,7 @@ main ()
300 return 0;
301 }
302 EOF
303 -gmp_compile="$HOST_CC conftest.c"
304 +gmp_compile="$HOST_CC $LDFLAGS conftest.c"
305 cc_for_build_works=no
306 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
307 (eval $gmp_compile) 2>&5
308 @@ -10052,7 +10052,7 @@ main ()
309 return 0;
310 }
311 EOF
312 -gmp_compile="$i conftest.c"
313 +gmp_compile="$i $LDFLAGS conftest.c"
314 cc_for_build_works=no
315 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
316 (eval $gmp_compile) 2>&5
317 @@ -10132,7 +10132,7 @@ main ()
318 }
319 EOF
320 for i in .exe ,ff8 ""; do
321 - gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"
322 + gmp_compile="$CC_FOR_BUILD $LDFLAGS conftest.c -o conftest$i"
323 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
324 (eval $gmp_compile) 2>&5
325 ac_status=$?
326 @@ -10168,7 +10168,7 @@ main (int argc, char **argv)
327 return 0;
328 }
329 EOF
330 -gmp_compile="$CC_FOR_BUILD conftest.c"
331 +gmp_compile="$CC_FOR_BUILD $LDFLAGS conftest.c"
332 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
333 (eval $gmp_compile) 2>&5
334 ac_status=$?
335 @@ -10210,7 +10210,7 @@ foo ()
336 return log (d);
337 }
338 EOF
339 -gmp_compile="$CC_FOR_BUILD conftest.c -lm"
340 +gmp_compile="$CC_FOR_BUILD $LDFLAGS conftest.c -lm"
341 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
342 (eval $gmp_compile) 2>&5
343 ac_status=$?
344 @@ -10543,7 +10543,7 @@ if test "$gmp_prog_cxx_works" = yes; the
345 int main (void) { return 0; }
346 EOF
347 echo "Test compile: " >&5
348 - gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS conftest.cc >&5"
349 + gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS $LDFLAGS conftest.cc >&5"
350 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_cxxcompile\""; } >&5
351 (eval $gmp_cxxcompile) 2>&5
352 ac_status=$?
353 @@ -10583,7 +10583,7 @@ using namespace foo;
354 int main (void) { return 0; }
355 EOF
356 echo "Test compile: namespace" >&5
357 - gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS conftest.cc >&5"
358 + gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS $LDFLAGS conftest.cc >&5"
359 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_cxxcompile\""; } >&5
360 (eval $gmp_cxxcompile) 2>&5
361 ac_status=$?
362 @@ -10629,7 +10629,7 @@ void someoutput (void) { std::cout << 12
363 int main (void) { return 0; }
364 EOF
365 echo "Test compile: std iostream" >&5
366 - gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS conftest.cc >&5"
367 + gmp_cxxcompile="$CXX $CPPFLAGS $CXXFLAGS $LDFLAGS conftest.cc >&5"
368 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_cxxcompile\""; } >&5
369 (eval $gmp_cxxcompile) 2>&5
370 ac_status=$?
371 @@ -27095,7 +27095,7 @@ for tmp_underscore in "" "_"; do
372 ${tmp_gsym_prefix}main$gmp_cv_asm_label_suffix
373 addl $ ${tmp_underscore}_GLOBAL_OFFSET_TABLE_, %ebx
374 EOF
375 - gmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&5 && $CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&5"
376 + gmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&5 && $CC $CFLAGS $CPPFLAGS $LDFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&5"
377 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
378 (eval $gmp_compile) 2>&5
379 ac_status=$?
380
4242
4343 #include "julia.h"
4444 #include "julia_internal.h"
45 #include "processor.h"
4546
4647 #ifdef _CPU_AARCH64_
4748 # include <sys/auxv.h>
332333 # else
333334 static crc32c_func_t crc32c_dispatch(unsigned long hwcap)
334335 {
335 if (hwcap & HWCAP_CRC32)
336 if (hwcap & (1 << JL_AArch64_crc))
336337 return crc32c_armv8;
337338 return jl_crc32c_sw;
338339 }
11001100 for (size_t i = 0; i < sysimg_fptrs.nclones; i++) {
11011101 if (diff == sysimg_fptrs.clone_offsets[i]) {
11021102 uint32_t idx = sysimg_fptrs.clone_idxs[i] & jl_sysimg_val_mask;
1103 frame0->linfo = sysimg_fvars_linfo[idx];
1103 if (idx < sysimg_fvars_n) // items after this were cloned but not referenced directly by a method (such as our ccall PLT thunks)
1104 frame0->linfo = sysimg_fvars_linfo[idx];
11041105 break;
11051106 }
11061107 }
627627 {
628628 // GC safe
629629 // Get the host information
630 std::string TripleName = sys::getDefaultTargetTriple();
631 Triple TheTriple(Triple::normalize(TripleName));
630 Triple TheTriple(sys::getProcessTriple());
632631
633632 const auto &target = jl_get_llvm_disasm_target();
634633 const auto &cpu = target.first;
635634 const auto &features = target.second;
636635
637636 std::string err;
638 const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, err);
637 const Target *TheTarget = TargetRegistry::lookupTarget(TheTriple.str(), err);
639638
640639 // Set up required helpers and streamer
641640 std::unique_ptr<MCStreamer> Streamer;
642641 SourceMgr SrcMgr;
643642
644 std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*TheTarget->createMCRegInfo(TripleName),TripleName));
643 std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*TheTarget->createMCRegInfo(TheTriple.str()), TheTriple.str()));
645644 assert(MAI && "Unable to create target asm info!");
646645
647 std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
646 std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TheTriple.str()));
648647 assert(MRI && "Unable to create target register info!");
649648
650649 std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
658657
659658 // Set up Subtarget and Disassembler
660659 std::unique_ptr<MCSubtargetInfo>
661 STI(TheTarget->createMCSubtargetInfo(TripleName, cpu, features));
660 STI(TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features));
662661 std::unique_ptr<MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI, Ctx));
663662 if (!DisAsm) {
664 jl_printf(JL_STDERR, "ERROR: no disassembler for target %s\n",
665 TripleName.c_str());
663 rstream << "ERROR: no disassembler for target " << TheTriple.str();
666664 return;
667665 }
668666 unsigned OutputAsmVariant = 0; // ATT or Intel-style assembly
669667
670 if (strcmp(asm_variant, "intel")==0) {
668 if (strcmp(asm_variant, "intel") == 0) {
671669 OutputAsmVariant = 1;
672670 }
673671 bool ShowEncoding = false;
254254 return 0;
255255 if (module_in_worklist(p->name->module))
256256 return 0;
257 if (p->name->wrapper != (jl_value_t*)p0) {
257 if (jl_unwrap_unionall(p->name->wrapper) != (jl_value_t*)p) {
258258 if (!type_recursively_external(p))
259259 return 0;
260260 }
742742 else if (jl_is_unionall(v)) {
743743 write_uint8(s->s, TAG_UNIONALL);
744744 jl_datatype_t *d = (jl_datatype_t*)jl_unwrap_unionall(v);
745 if (jl_is_datatype(d) && d->name->wrapper == v &&
745 if (jl_is_datatype(d) && jl_unwrap_unionall(d->name->wrapper) == (jl_value_t*)d &&
746746 !module_in_worklist(d->name->module)) {
747747 write_uint8(s->s, 1);
748748 jl_serialize_value(s, d->name->module);
3232 JL_DLLEXPORT size_t jl_get_tls_world_age(void)
3333 {
3434 return jl_get_ptls_states()->world_age;
35 }
36
37 JL_DLLEXPORT jl_value_t *jl_invoke(jl_method_instance_t *meth, jl_value_t **args, uint32_t nargs)
38 {
39 jl_callptr_t fptr = meth->invoke;
40 if (fptr != jl_fptr_trampoline) {
41 return fptr(meth, args, nargs);
42 }
43 else {
44 // if this hasn't been inferred (compiled) yet,
45 // inferring it might not be able to handle the world range
46 // so we just do a generic apply here
47 // because that might actually be faster
48 // since it can go through the unrolled caches for this world
49 // and if inference is successful, this meth would get updated anyways,
50 // and we'll get the fast path here next time
51
52 // TODO: if `meth` came from an `invoke` call, we should make sure
53 // meth->def is called instead of doing normal dispatch.
54
55 return jl_apply(args, nargs);
56 }
5735 }
5836
5937 /// ----- Handling for Julia callbacks ----- ///
21992177 return (jl_value_t*)entry;
22002178 }
22012179
2180 jl_value_t *jl_gf_invoke_by_method(jl_method_t *method, jl_value_t **args, size_t nargs);
2181
22022182 // invoke()
22032183 // this does method dispatch with a set of types to match other than the
22042184 // types of the actual arguments. this means it sometimes does NOT call the
22112191 jl_value_t *jl_gf_invoke(jl_value_t *types0, jl_value_t **args, size_t nargs)
22122192 {
22132193 size_t world = jl_get_ptls_states()->world_age;
2214 jl_svec_t *tpenv = jl_emptysvec;
2215 jl_tupletype_t *tt = NULL;
22162194 jl_value_t *types = NULL;
2217 JL_GC_PUSH3(&types, &tpenv, &tt);
2195 JL_GC_PUSH1(&types);
22182196 jl_value_t *gf = args[0];
22192197 types = jl_argtype_with_function(gf, types0);
2220 jl_methtable_t *mt = jl_gf_mtable(gf);
22212198 jl_typemap_entry_t *entry = (jl_typemap_entry_t*)jl_gf_invoke_lookup(types, world);
22222199
22232200 if ((jl_value_t*)entry == jl_nothing) {
22272204
22282205 // now we have found the matching definition.
22292206 // next look for or create a specialization of this definition.
2230
2231 jl_method_t *method = entry->func.method;
2207 JL_GC_POP();
2208 return jl_gf_invoke_by_method(entry->func.method, args, nargs);
2209 }
2210
2211 jl_value_t *jl_gf_invoke_by_method(jl_method_t *method, jl_value_t **args, size_t nargs)
2212 {
2213 size_t world = jl_get_ptls_states()->world_age;
22322214 jl_method_instance_t *mfunc = NULL;
22332215 jl_typemap_entry_t *tm = NULL;
2216 jl_methtable_t *mt = jl_gf_mtable(args[0]);
2217 jl_svec_t *tpenv = jl_emptysvec;
2218 jl_tupletype_t *tt = NULL;
2219 JL_GC_PUSH2(&tpenv, &tt);
22342220 if (method->invokes.unknown != NULL)
22352221 tm = jl_typemap_assoc_exact(method->invokes, args, nargs, jl_cachearg_offset(mt), world);
22362222 if (tm) {
22472233 if (method->invokes.unknown == NULL)
22482234 method->invokes.unknown = jl_nothing;
22492235
2250 mfunc = cache_method(mt, &method->invokes, entry->func.value, tt, method, world, tpenv, 1);
2236 mfunc = cache_method(mt, &method->invokes, (jl_value_t*)method, tt, method, world, tpenv, 1);
22512237 JL_UNLOCK(&method->writelock);
22522238 }
22532239 JL_GC_POP();
23002286 JL_GC_POP();
23012287 JL_UNLOCK(&method->writelock);
23022288 return (jl_value_t*)mfunc;
2289 }
2290
2291 JL_DLLEXPORT jl_value_t *jl_invoke(jl_method_instance_t *meth, jl_value_t **args, uint32_t nargs)
2292 {
2293 jl_callptr_t fptr = meth->invoke;
2294 if (fptr != jl_fptr_trampoline) {
2295 return fptr(meth, args, nargs);
2296 }
2297 else {
2298 // if this hasn't been inferred (compiled) yet,
2299 // inferring it might not be able to handle the world range
2300 // so we just do a generic apply here
2301 // because that might actually be faster
2302 // since it can go through the unrolled caches for this world
2303 // and if inference is successful, this meth would get updated anyways,
2304 // and we'll get the fast path here next time
2305
2306 jl_method_instance_t *mfunc = jl_lookup_generic_(args, nargs,
2307 jl_int32hash_fast(jl_return_address()),
2308 jl_get_ptls_states()->world_age);
2309 // check whether `jl_apply_generic` would call the right method
2310 if (mfunc->def.method == meth->def.method)
2311 return mfunc->invoke(mfunc, args, nargs);
2312
2313 // no; came from an `invoke` call
2314 return jl_gf_invoke_by_method(meth->def.method, args, nargs);
2315 }
23032316 }
23042317
23052318 // Return value is rooted globally
23942407 closure->max_valid = ml->max_world;
23952408 }
23962409 }
2410 // In some corner cases type intersection is conservative and returns something
2411 // for intersect(A, B) even though A is a dispatch tuple and !(A <: B).
2412 // For dispatch purposes in such a case we know there's no match. This check
2413 // fixes issue #30394.
2414 if (jl_is_dispatch_tupletype(closure->match.type) && !closure->match.issubty)
2415 return 1;
23972416 // a method is shadowed if type <: S <: m->sig where S is the
23982417 // signature of another applicable method
23992418 /*
395395 (vararg (let ((l (if (null? pargl) '() (last pargl))))
396396 (if (or (vararg? l) (varargexpr? l))
397397 (list l) '())))
398 ;; positional args with vararg
399 (pargl-all pargl)
398400 ;; positional args without vararg
399401 (pargl (if (null? vararg) pargl (butlast pargl)))
400402 ;; positional args with everything required; for use by the core function
423425 (filter nospecialize-meta? kargl)))
424426 ;; body statements
425427 (stmts (cdr body))
426 (positional-sparams
427 (filter (lambda (s)
428 (let ((name (car s)))
429 (or (expr-contains-eq name (cons 'list pargl))
430 (and (pair? vararg) (expr-contains-eq name (car vararg)))
431 (not (expr-contains-eq name (cons 'list kargl))))))
432 sparams))
428 (positional-sparams (filter-sparams (cons 'list pargl-all) sparams))
433429 (keyword-sparams
434430 (filter (lambda (s)
435431 (not (any (lambda (p) (eq? (car p) (car s)))
461457
462458 ;; call with no keyword args
463459 ,(method-def-expr-
464 name positional-sparams (append pargl vararg)
460 name positional-sparams pargl-all
465461 `(block
466462 ,@(without-generated prologue)
467463 ,(let (;; call mangled(vals..., [rest_kw,] pargs..., [vararg]...)
477473
478474 ;; call with unsorted keyword args. this sorts and re-dispatches.
479475 ,(method-def-expr-
480 name
481 ;; remove sparams that don't occur, to avoid printing the warning twice
482 (filter-sparams (cons 'list argl) positional-sparams)
476 name positional-sparams
483477 `((|::|
484478 ;; if there are optional positional args, we need to be able to reference the function name
485479 ,(if (any kwarg? pargl) (gensy) UNUSED)
29972991 (kill))
29982992 (cdr e)))
29992993 (else
3000 (mark-used e)
2994 (if (eq? (car e) '=)
2995 (visit (caddr e))
2996 (mark-used e))
30012997 (if (and (or (eq? (car e) '=)
30022998 (and (eq? (car e) 'method) (length> e 2)))
30032999 (has? unused (cadr e)))
206206 MDNode *n = L->getLoopID();
207207 if (!n) {
208208 // Loop does not have a LoopID yet, so give it one.
209 n = MDNode::get(Lh->getContext(), ArrayRef<Metadata *>(NULL));
210 n->replaceOperandWith(0, n);
209 auto temp_n = MDNode::getTemporary(Lh->getContext(), ArrayRef<Metadata *>(NULL));
210 temp_n->replaceOperandWith(0, temp_n.get());
211 n = MDNode::replaceWithPermanent(std::move(temp_n));
211212 L->setLoopID(n);
212213 }
213214
10141014 for (i = 0; i < sysimg_fvars_max; i++) {
10151015 uintptr_t val = (uintptr_t)&linfos[i];
10161016 uint32_t offset = load_uint32(&val);
1017 linfos[i] = NULL;
10171018 if (offset != 0) {
10181019 int specfunc = 1;
10191020 if (offset & ((uintptr_t)1 << (8 * sizeof(uint32_t) - 1))) {
117117
118118 decimal_point_pos = NULL;
119119
120 p = nptr;
121
122 /* parse leading spaces */
123 while (isspace((unsigned char)*p)) {
124 p++;
125 }
126
120127 /* Parse infinities and nans */
121 val = parse_inf_or_nan(nptr, endptr);
122 if (*endptr != nptr)
128 val = parse_inf_or_nan(p, endptr);
129 if (*endptr != p)
123130 return val;
124131
125132 /* Set errno to zero, so that we can distinguish zero results
129136 /* We process the optional sign manually, then pass the remainder to
130137 the system strtod. This ensures that the result of an underflow
131138 has the correct sign. */
132 p = nptr;
133
134 /* parse leading spaces */
135 while (isspace((unsigned char)*p)) {
136 p++;
137 }
138139
139140 /* Process leading sign, if present */
140141 if (*p == '-') {
134134 extract_imports!(imports, x) = imports
135135 function extract_imports!(imports, ex::Expr)
136136 if Meta.isexpr(ex, (:import, :using))
137 m = ex.args[1]
138 if isa(m, Expr) && m.head === :(:)
139 push!(imports, m.args[1].args[1])
140 else
141 for a in ex.args
142 push!(imports, a.args[1])
143 end
144 end
137 push!(imports, ex)
145138 elseif Meta.isexpr(ex, :let)
146139 extract_imports!(imports, ex.args[2])
147140 elseif Meta.isexpr(ex, (:toplevel, :block))
148 for i in eachindex(ex.args)
149 extract_imports!(imports, ex.args[i])
141 for arg in ex.args
142 extract_imports!(imports, arg)
150143 end
151144 end
152145 return imports
153146 end
154 extract_imports(x) = extract_imports!(Symbol[], x)
147 extract_imports(x) = extract_imports!(Any[], x)
155148
156149 """
157150 @everywhere [procs()] expr
182175 end
183176
184177 macro everywhere(procs, ex)
185 imps = [Expr(:import, m) for m in extract_imports(ex)]
178 imps = extract_imports(ex)
186179 return quote
187180 $(isempty(imps) ? nothing : Expr(:toplevel, imps...)) # run imports locally first
188181 let ex = $(Expr(:quote, ex)), procs = $(esc(procs))
77 include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl"))
88
99 @test Distributed.extract_imports(:(begin; import Foo, Bar; let; using Baz; end; end)) ==
10 [:Foo, :Bar, :Baz]
10 Any[:(import Foo, Bar), :(using Baz)]
1111
1212 # Test a few "remote" invocations when no workers are present
1313 @test remote(myid)() == 1
167167
168168 function rmul!(A::AbstractMatrix, D::Diagonal)
169169 @assert !has_offset_axes(A)
170 A .= A .* transpose(D.diag)
170 A .= A .* permutedims(D.diag)
171171 return A
172172 end
173173
255255
256256 function lmul!(adjA::Adjoint{<:Any,<:Diagonal}, B::AbstractMatrix)
257257 A = adjA.parent
258 return lmul!(conj(A.diag), B)
258 return lmul!(adjoint(A), B)
259259 end
260260 function lmul!(transA::Transpose{<:Any,<:Diagonal}, B::AbstractMatrix)
261261 A = transA.parent
262 return lmul!(A.diag, B)
262 return lmul!(transpose(A), B)
263263 end
264264
265265 function rmul!(A::AbstractMatrix, adjB::Adjoint{<:Any,<:Diagonal})
266266 B = adjB.parent
267 return rmul!(A, conj(B.diag))
267 return rmul!(A, adjoint(B))
268268 end
269269 function rmul!(A::AbstractMatrix, transB::Transpose{<:Any,<:Diagonal})
270270 B = transB.parent
271 return rmul!(A, B.diag)
271 return rmul!(A, transpose(B))
272272 end
273273
274274 # Get ambiguous method if try to unify AbstractVector/AbstractMatrix here using AbstractVecOrMat
507507 *(x::Adjoint{<:Any,<:AbstractVector}, D::Diagonal) = Adjoint(map((t,s) -> t'*s, D.diag, parent(x)))
508508 *(x::Adjoint{<:Any,<:AbstractVector}, D::Diagonal, y::AbstractVector) =
509509 mapreduce(t -> t[1]*t[2]*t[3], +, zip(x, D.diag, y))
510 *(x::Transpose{<:Any,<:AbstractVector}, D::Diagonal) = Transpose(map(*, D.diag, parent(x)))
510 *(x::Transpose{<:Any,<:AbstractVector}, D::Diagonal) = Transpose(map((t,s) -> transpose(t)*s, D.diag, parent(x)))
511511 *(x::Transpose{<:Any,<:AbstractVector}, D::Diagonal, y::AbstractVector) =
512512 mapreduce(t -> t[1]*t[2]*t[3], +, zip(x, D.diag, y))
513 # TODO: these methods will yield row matrices, rather than adjoint/transpose vectors
514513
515514 function cholesky!(A::Diagonal, ::Val{false} = Val(false); check::Bool = true)
516515 info = 0
440440 fullBB = copyto!(Matrix{Matrix{T}}(undef, 2, 2), BB)
441441 for (transform1, transform2) in ((identity, identity),
442442 (identity, adjoint ), (adjoint, identity ), (adjoint, adjoint ),
443 (identity, transpose), (transpose, identity ), (transpose, transpose) )
443 (identity, transpose), (transpose, identity ), (transpose, transpose),
444 (identity, Adjoint ), (Adjoint, identity ), (Adjoint, Adjoint ),
445 (identity, Transpose), (Transpose, identity ), (Transpose, Transpose))
444446 @test *(transform1(D), transform2(B))::typeof(D) ≈ *(transform1(Matrix(D)), transform2(Matrix(B))) atol=2 * eps()
445447 @test *(transform1(DD), transform2(BB))::typeof(DD) == *(transform1(fullDD), transform2(fullBB))
448 end
449 M = randn(T, 5, 5)
450 MM = [randn(T, 2, 2) for _ in 1:2, _ in 1:2]
451 for transform in (identity, adjoint, transpose, Adjoint, Transpose)
452 @test lmul!(transform(D), copy(M)) == *(transform(Matrix(D)), M)
453 @test rmul!(copy(M), transform(D)) == *(M, transform(Matrix(D)))
454 @test lmul!(transform(DD), copy(MM)) == *(transform(fullDD), MM)
455 @test rmul!(copy(MM), transform(DD)) == *(MM, transform(fullDD))
446456 end
447457 end
448458 end
453463 end
454464
455465 @testset "Multiplication with Adjoint and Transpose vectors (#26863)" begin
456 x = rand(5)
457 D = Diagonal(rand(5))
458 @test x'*D*x == (x'*D)*x == (x'*Array(D))*x
459 @test Transpose(x)*D*x == (Transpose(x)*D)*x == (Transpose(x)*Array(D))*x
466 x = collect(1:2)
467 xt = transpose(x)
468 A = reshape([[1 2; 3 4], zeros(Int,2,2), zeros(Int, 2, 2), [5 6; 7 8]], 2, 2)
469 D = Diagonal(A)
470 @test x'*D == x'*A == copy(x')*D == copy(x')*A
471 @test xt*D == xt*A == copy(xt)*D == copy(xt)*A
472 y = [x, x]
473 yt = transpose(y)
474 @test y'*D*y == (y'*D)*y == (y'*A)*y
475 @test yt*D*y == (yt*D)*y == (yt*A)*y
460476 end
461477
462478 @testset "Triangular division by Diagonal #27989" begin
00 PKG_BRANCH = master
1 PKG_SHA1 = 93b6d6de857dc88e665d2c64397852ab9701ba24
1 PKG_SHA1 = 1609a05aee5d5960670738d8d834d91235bd6b1e
513513 # jump forward to the end of the inlining chain
514514 # avoiding an extra (slow) lookup of `ip` in `lidict`
515515 # and an extra chain of them in `down`
516 # note that we may even have this === parent (if we're ignoring this frame ip)
516517 this = builder_value[fastkey]
517518 let this = this
518519 while this !== parent
531532 frame = (frames isa Vector ? frames[i] : frames)
532533 !C && frame.from_c && continue
533534 key = (T === UInt64 ? ip : frame)
534 down = parent.down
535 this = get!(down, key) do
535 this = get!(parent.down, key) do
536536 return StackFrameTree{T}()
537537 end
538538 this.frame = frame
352352 function get_value_getfield(ex::Expr, fn)
353353 # Example :((top(getfield))(Base,:max))
354354 val, found = get_value_getfield(ex.args[2],fn) #Look up Base in Main and returns the module
355 found || return (nothing, false)
355 (found && length(ex.args) >= 3) || return (nothing, false)
356356 return get_value_getfield(ex.args[3], val) #Look up max in Base and returns the function if found.
357357 end
358358 get_value_getfield(sym, fn) = get_value(sym, fn)
406406 elseif sym.head === :ref
407407 # some simple cases of `expand`
408408 return try_get_type(Expr(:call, GlobalRef(Base, :getindex), sym.args...), fn)
409 elseif sym.head === :.
409 elseif sym.head === :. && sym.args[2] isa QuoteNode # second check catches broadcasting
410410 return try_get_type(Expr(:call, GlobalRef(Core, :getfield), sym.args...), fn)
411411 end
412412 return (Any, false)
431431 args_ex = Any[]
432432 func, found = get_value(ex_org.args[1], context_module)
433433 !found && return Completion[]
434 for ex in ex_org.args[2:end]
435 val, found = get_type(ex, context_module)
436 push!(args_ex, val)
437 end
434
435 funargs = ex_org.args[2:end]
436 # handle broadcasting, but only handle number of arguments instead of
437 # argument types
438 if ex_org.head === :. && ex_org.args[2] isa Expr
439 for _ in ex_org.args[2].args
440 push!(args_ex, Any)
441 end
442 else
443 for ex in funargs
444 val, found = get_type(ex, context_module)
445 push!(args_ex, val)
446 end
447 end
448
438449 out = Completion[]
439450 t_in = Tuple{Core.Typeof(func), args_ex...} # Input types
440451 na = length(args_ex)+1
609620
610621 # Make sure that only bslash_completions is working on strings
611622 inc_tag==:string && return String[], 0:-1, false
612
613623 if inc_tag == :other && should_method_complete(partial)
614624 frange, method_name_end = find_start_brace(partial)
615625 ex = Meta.parse(partial[frange] * ")", raise=false, depwarn=false)
616 if isa(ex, Expr) && ex.head==:call
617 return complete_methods(ex, context_module), first(frange):method_name_end, false
626
627 if isa(ex, Expr)
628 if ex.head==:call
629 return complete_methods(ex, context_module), first(frange):method_name_end, false
630 elseif ex.head==:. && ex.args[2] isa Expr && ex.args[2].head==:tuple
631 return complete_methods(ex, context_module), first(frange):(method_name_end - 1), false
632 end
618633 end
619634 elseif inc_tag == :comment
620635 return Completion[], 0:-1, false
2020
2121 function _helpmode(io::IO, line::AbstractString)
2222 line = strip(line)
23 x = Meta.parse(line, raise = false, depwarn = false)
2324 expr =
24 if haskey(keywords, Symbol(line))
25 if haskey(keywords, Symbol(line)) || isexpr(x, :error) || isexpr(x, :invalid)
2526 # Docs for keywords must be treated separately since trying to parse a single
2627 # keyword such as `function` would throw a parse error due to the missing `end`.
2728 Symbol(line)
2829 else
29 x = Meta.parse(line, raise = false, depwarn = false)
3030 # Retrieving docs for macros requires us to make a distinction between the text
3131 # `@macroname` and `@macroname()`. These both parse the same, but are used by
3232 # the docsystem to return different results. The first returns all documentation
971971 @test Base.eval(REPL._helpmode(buf, line)) isa Union{Markdown.MD,Nothing}
972972 end
973973
974 # PR 30754, Issues #22013, #24871, #26933, #29282, #29361, #30348
975 for line in ["′", "abstract", "type", "|=", ".="]
976 @test occursin("No documentation found.",
977 sprint(show, Base.eval(REPL._helpmode(IOBuffer(), line))::Union{Markdown.MD,Nothing}))
978 end
979
974980 # PR #27562
975981 fake_repl() do stdin_write, stdout_read, repl
976982 repltask = @async begin
959959 @test s[r] == "y"
960960 end
961961
962 let s = ":(function foo(::Int) end).args[1].args[2]."
963 c, r = test_complete_context(s)
964 @test c == Any[]
965 end
966
967 let s = "log(log.(x),"
968 c, r = test_complete_context(s)
969 @test !isempty(c)
970 end
971
962972 let s = "Base.return_types(getin"
963973 c, r = test_complete_context(s)
964974 @test "getindex" in c
976986 @test !res
977987 @test c[1] == string(first(methods(Main.CompletionFoo.test, Tuple{Int, Int})))
978988 @test length(c) == 3
989 @test r == 1:4
990 @test s[r] == "test"
991 end
992
993 let s = "test.(1,1, "
994 c, r, res = test_complete_context(s)
995 @test !res
996 @test length(c) == 4
979997 @test r == 1:4
980998 @test s[r] == "test"
981999 end
88 lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
99 so_many_as_array = repeat([0x61], 1000000)
1010 so_many_as_tuple = ntuple((i) -> 0x61, 1000000)
11 file = ".sha" # Subject to change
11 tempdir = mktempdir()
12 file = joinpath(tempdir, ".sha")
1213 fIO = open(file, "w")
1314 write(fIO, '\0')
1415 close(fIO)
273274 # test error if eltype of input is not UInt8
274275 for f in sha_funcs
275276 global nerrors
277 data = UInt32[0x23467, 0x324775]
276278 try
277 f(UInt32[0x23467, 0x324775])
278 warn("Non-UInt8 Arrays should fail")
279 nerrors += 1
280 catch
281 end
279 f(data)
280 catch ex
281 if ex isa MethodError &&
282 ex.f === f &&
283 ex.args === (data,)
284 continue
285 end
286 rethrow()
287 end
288 warn("Non-UInt8 Arrays should fail")
289 nerrors += 1
282290 end
283291
284292 # Clean up the I/O mess
285293 rm(file)
294 rm(tempdir)
286295
287296 if nerrors == 0
288297 VERBOSE && println("ALL OK")
382382 vals, ks, rows = _fusedupdate_all(rowsentinel, activerow, rows, ks, stopks, As)
383383 Cx = f(vals...)
384384 if !_iszero(Cx)
385 Ck > spaceC && (spaceC = expandstorage!(C, Ck + min(length(C), _sumnnzs(As...)) - (sum(ks) - N)))
385 Ck > spaceC && (spaceC = expandstorage!(C, min(length(C), Ck + _sumnnzs(As...) - (sum(ks) - N))))
386386 storedinds(C)[Ck] = activerow
387387 storedvals(C)[Ck] = Cx
388388 Ck += 1
15571557 sparse(s::UniformScaling, m::Integer, n::Integer) = sparse(s, Dims((m, n)))
15581558
15591559 # TODO: More appropriate location?
1560 conj!(A::SparseMatrixCSC) = (@inbounds broadcast!(conj, A.nzval, A.nzval); A)
1561 (-)(A::SparseMatrixCSC) = SparseMatrixCSC(A.m, A.n, copy(A.colptr), copy(A.rowval), map(-, A.nzval))
1560 function conj!(A::SparseMatrixCSC)
1561 map!(conj, nzvalview(A), nzvalview(A))
1562 return A
1563 end
1564 function (-)(A::SparseMatrixCSC)
1565 nzval = similar(A.nzval)
1566 map!(-, view(nzval, 1:nnz(A)), nzvalview(A))
1567 return SparseMatrixCSC(A.m, A.n, copy(A.colptr), copy(A.rowval), nzval)
1568 end
15621569
15631570 # the rest of real, conj, imag are handled correctly via AbstractArray methods
1564 conj(A::SparseMatrixCSC{<:Complex}) =
1565 SparseMatrixCSC(A.m, A.n, copy(A.colptr), copy(A.rowval), conj(A.nzval))
1571 function conj(A::SparseMatrixCSC{<:Complex})
1572 nzval = similar(A.nzval)
1573 map!(conj, view(nzval, 1:nnz(A)), nzvalview(A))
1574 return SparseMatrixCSC(A.m, A.n, copy(A.colptr), copy(A.rowval), nzval)
1575 end
15661576 imag(A::SparseMatrixCSC{Tv,Ti}) where {Tv<:Real,Ti} = spzeros(Tv, Ti, A.m, A.n)
15671577
15681578 ## Binary arithmetic and boolean operators
19671977 return SparseMatrixCSC(m, nJ, colptrS, rowvalS, nzvalS)
19681978 end
19691979
1970 getindex_traverse_col(::AbstractUnitRange, lo::Int, hi::Int) = lo:hi
1971 getindex_traverse_col(I::StepRange, lo::Int, hi::Int) = step(I) > 0 ? (lo:1:hi) : (hi:-1:lo)
1980 getindex_traverse_col(::AbstractUnitRange, lo::Integer, hi::Integer) = lo:hi
1981 getindex_traverse_col(I::StepRange, lo::Integer, hi::Integer) = step(I) > 0 ? (lo:1:hi) : (hi:-1:lo)
19721982
19731983 function getindex(A::SparseMatrixCSC{Tv,Ti}, I::AbstractRange, J::AbstractVector) where {Tv,Ti<:Integer}
19741984 @assert !has_offset_axes(A, I, J)
631631 @test minimum(sparse([1, 2], [1, 2], ones(Int32, 2)), dims = 1) isa Matrix
632632 end
633633
634 @testset "issue #31758: out of bounds write in _map_zeropres!" begin
635 y = sparsevec([2,7], [1., 2.], 10)
636 x1 = sparsevec(fill(1.0, 10))
637 x2 = sparsevec([2,7], [1., 2.], 10)
638 x3 = sparsevec(fill(1.0, 10))
639 f(x, y, z) = x == y == z == 0 ? 0.0 : NaN
640 y .= f.(x1, x2, x3)
641 @test all(isnan, y)
642 end
643
634644 end # module
8989 @test_throws DimensionMismatch map(|, sqrboolmat, colboolmat)
9090 @test_throws DimensionMismatch map(xor, sqrboolmat, colboolmat)
9191 end
92 end
93
94 @testset "Issue #30006" begin
95 SparseMatrixCSC{Float64,Int32}(spzeros(3,3))[:, 1] == [1, 2, 3]
9296 end
9397
9498 @testset "concatenation tests" begin
707711 ss116 = sparse(aa116)
708712
709713 @test ss116[:,:] == copy(ss116)
714
715 @test convert(SparseMatrixCSC{Float32,Int32}, sd116)[2:5,:] == convert(SparseMatrixCSC{Float32,Int32}, sd116[2:5,:])
710716
711717 # range indexing
712718 @test Array(ss116[i,:]) == aa116[i,:]
23062312 @test m2.module == SparseArrays
23072313 end
23082314
2315 @testset "unary operations on matrices where length(nzval)>nnz" begin
2316 # this should create a sparse matrix with length(nzval)>nnz
2317 A = SparseMatrixCSC(Complex{BigInt}[1+im 2+2im]')'[1:1, 2:2]
2318 # ...ensure it does! If necessary, the test needs to be updated to use
2319 # another mechanism to create a suitable A.
2320 @assert length(A.nzval) > nnz(A)
2321 @test -A == fill(-2-2im, 1, 1)
2322 @test conj(A) == fill(2-2im, 1, 1)
2323 conj!(A)
2324 @test A == fill(2-2im, 1, 1)
2325 end
2326
23092327 end # module
33 [deps]
44 Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
55 LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
6 Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
67 SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
78
89 [extras]
10 DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
11 Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12 Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
913 Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10 Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
11 DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
12 Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1314
1415 [targets]
1516 test = ["Test", "Random", "DelimitedFiles", "Serialization"]
99
1010 using SparseArrays
1111 import SparseArrays: nnz
12
13 import Serialization: AbstractSerializer, deserialize
1214
1315 import ..increment, ..increment!, ..decrement, ..decrement!
1416
191193 F.numeric != C_NULL && print(io, '\n', F.numeric)
192194 end
193195
196 function deserialize(s::AbstractSerializer, t::Type{UmfpackLU{Tv,Ti}}) where {Tv,Ti}
197 symbolic = deserialize(s)
198 numeric = deserialize(s)
199 m = deserialize(s)
200 n = deserialize(s)
201 colptr = deserialize(s)
202 rowval = deserialize(s)
203 nzval = deserialize(s)
204 status = deserialize(s)
205 obj = UmfpackLU{Tv,Ti}(symbolic, numeric, m, n, colptr, rowval, nzval, status)
206
207 finalizer(umfpack_free_symbolic, obj)
208
209 return obj
210 end
211
194212 ## Wrappers for UMFPACK functions
195213
196214 # generate the name of the C function according to the value and integer types
00 # This file is a part of Julia. License is MIT: https://julialang.org/license
11
22 using SuiteSparse: increment!
3 using Serialization
34 using LinearAlgebra: Adjoint, Transpose, SingularException
45
56 @testset "UMFPACK wrappers" begin
175176 end
176177 end
177178
179 @testset "deserialization" begin
180 A = 10*I + sprandn(10, 10, 0.4)
181 F1 = lu(A)
182 b = IOBuffer()
183 serialize(b, F1)
184 seekstart(b)
185 F2 = deserialize(b)
186 for nm in (:colptr, :m, :n, :nzval, :rowval, :status)
187 @test getfield(F1, nm) == getfield(F2, nm)
188 end
189 end
190
178191 end
18201820 sol
18211821 end
18221822 @test g15276() isa Vector{Int}
1823
1824 function inbounds_30563()
1825 local y
1826 @inbounds for i in 1:10
1827 y = (m->2i)(0)
1828 end
1829 return y
1830 end
1831 @test Base.return_types(inbounds_30563, ()) == Any[Int]
18231832
18241833 # issue #27316 - inference shouldn't hang on these
18251834 f27316(::Vector) = nothing
20672076 val
20682077 end
20692078 @test Base.return_types(f29036, (String, Int)) == Any[Char]
2079
2080 # issue #30394
2081 mutable struct Base30394
2082 a::Int
2083 end
2084
2085 mutable struct Foo30394
2086 foo_inner::Base30394
2087 Foo30394() = new(Base30394(1))
2088 end
2089
2090 mutable struct Foo30394_2
2091 foo_inner::Foo30394
2092 Foo30394_2() = new(Foo30394())
2093 end
2094
2095 f30394(foo::T1, ::Type{T2}) where {T2, T1 <: T2} = foo
2096
2097 f30394(foo, T2) = f30394(foo.foo_inner, T2)
2098
2099 @test Base.return_types(f30394, (Foo30394_2, Type{Base30394})) == Any[Base30394]
0 # Tests for SROA
1
2 mutable struct Foo30594; x::Float64; end
3 Base.copy(x::Foo30594) = Foo30594(x.x)
4 function add!(p::Foo30594, off::Foo30594)
5 p.x += off.x
6 return p
7 end
8 Base.:(+)(a::Foo30594, b::Foo30594) = add!(copy(a), b)
9
10 let results = Float64[]
11 @noinline use30594(x) = push!(results, x.x); nothing
12 function foo30594(cnt::Int, dx::Int)
13 step = Foo30594(dx)
14 curr = step + Foo30594(1)
15 for i in 1:cnt
16 use30594(curr)
17 curr = curr + step
18 end
19 nothing
20 end
21
22 foo30594(4, -1)
23 @test results == [0.0, -1.0, -2.0, -3.0]
24 end
25
26 # Issue #29983
27 # This one is a bit hard to trigger, but the key is to create a case
28 # where SROA needs to introduce an intermediate type-unstable phi node
29 struct Foo29983{T}
30 x::Tuple{T}
31 end
32 struct Bar29983{S}
33 x::S
34 end
35 Base.:+(a::T, b::Bar29983{S}) where {T, S} = Bar29983(a + b.x)
36 Base.:+(a::Bar29983{S}, b::T) where {T, S} = b + a
37 Base.:+(a::Bar29983{S}, b::Bar29983{T}) where {T, S} = Bar29983(a.x + b.x)
38 Base.:+(a::Foo29983, b::Foo29983) = Foo29983((a.x[1] + b.x[1],))
39
40 function f(x::Vector{T}) where {T}
41 x1 = Foo29983((x[1],))
42 la1 = Foo29983((x[1],))
43 f1 = Foo29983((0,))
44 for _ in 1:2
45 f1 += la1
46 end
47 return f1
48 end
49
50 @test f([Bar29983(1.0)]).x[1].x == 2.0
8383 @test c[1] === c[2]
8484 end
8585
86 # issue #30911
87 @test deepcopy(Array{Int,N} where N) == Array{Int,N} where N
88
8689 # issue #14027
8790 struct Nullable14027{T}
8891 hasvalue::Bool
24302430 const T24460 = Tuple{T,T} where T
24312431 g24460() = invoke(f24460, T24460, 1, 2)
24322432 @test @inferred(g24460()) === 2.0
2433
2434 # issue #30679
2435 @noinline function f30679(::DataType)
2436 b = IOBuffer()
2437 write(b, 0x00)
2438 2
2439 end
2440 @noinline function f30679(t::Type{Int})
2441 x = invoke(f30679, Tuple{DataType}, t)
2442 b = IOBuffer()
2443 write(b, 0x00)
2444 return x + 40
2445 end
2446 @test f30679(Int) == 42
24332447
24342448 call_lambda1() = (()->x)(1)
24352449 call_lambda2() = ((x)->x)()
548548 @test ps isa Iterators.Pairs
549549 @test collect(ps) == [1 => :a, 2 => :b]
550550 end
551
552 @testset "Stateful fix #30643" begin
553 @test Base.IteratorSize(1:10) isa Base.HasShape
554 a = Iterators.Stateful(1:10)
555 @test Base.IteratorSize(a) isa Base.HasLength
556 @test length(a) == 10
557 @test length(collect(a)) == 10
558 @test length(a) == 0
559 b = Iterators.Stateful(Iterators.take(1:10,3))
560 @test Base.IteratorSize(b) isa Base.HasLength
561 @test length(b) == 3
562 @test length(collect(b)) == 3
563 @test length(b) == 0
564 c = Iterators.Stateful(Iterators.countfrom(1))
565 @test Base.IteratorSize(c) isa Base.IsInfinite
566 @test length(Iterators.take(c,3)) == 3
567 @test length(collect(Iterators.take(c,3))) == 3
568 d = Iterators.Stateful(Iterators.filter(isodd,1:10))
569 @test Base.IteratorSize(d) isa Base.SizeUnknown
570 @test length(collect(Iterators.take(d,3))) == 3
571 @test length(collect(d)) == 2
572 @test length(collect(d)) == 0
573 end
574
116116 @test kwf7(1.5;k=2.5) === Float64
117117 @test_throws MethodError kwf7(1.5)
118118 @test_throws TypeError kwf7(1.5; k=2)
119
120 # issue #30792
121 g30792(a::C; b=R(1)) where {R <: Real, C <: Union{R, Complex{R}}} = R
122 @test g30792(1.0) === Float64
123 @test g30792(1.0im) === Float64
124 @test g30792(1.0im, b=1) === Float64
125 @test_throws MethodError g30792("")
126 f30792(a::C; b::R=R(1)) where {R <: Real, C <: Union{R, Complex{R}}} = R
127 @test f30792(2im) === Int
128 @test f30792(2im, b=3) === Int
129 @test_throws TypeError f30792(2im, b=3.0)
119130 end
120131 # try to confuse it with quoted symbol
121132 kwf8(x::MIME{:T};k::T=0) where {T} = 0
202202 cmp_showf(Base.print_matrix, io, OffsetArray(rand(5,10^3), (10,-9))) # rows fit
203203 cmp_showf(Base.print_matrix, io, OffsetArray(rand(10^3,10^3), (10,-9))) # neither fits
204204 cmp_showf(Base.print_matrix, io, OffsetArray(reshape(range(-0.212121212121, stop=2/11, length=3*29), 3, 29), (-2, -15)); options=(:displaysize=>(53,210),))
205 cmp_showf(show, io, OffsetArray(collect(1:100), (100,))) # issue #31641
206
205207 targets1 = ["0-dimensional $OAs_name.OffsetArray{Float64,0,Array{Float64,0}}:\n1.0",
206208 "$OAs_name.OffsetArray{Float64,1,Array{Float64,1}} with indices 2:2:\n 1.0",
207209 "$OAs_name.OffsetArray{Float64,2,Array{Float64,2}} with indices 2:2×3:3:\n 1.0",
267267
268268 # parsing complex numbers (#22250)
269269 @testset "complex parsing" begin
270 for r in (1,0,-1), i in (1,0,-1), sign in ('-','+'), Im in ("i","j","im")
271 for s1 in (""," "), s2 in (""," "), s3 in (""," "), s4 in (""," ")
270 for sign in ('-','+'), Im in ("i","j","im"), s1 in (""," "), s2 in (""," "), s3 in (""," "), s4 in (""," ")
271 for r in (1,0,-1), i in (1,0,-1),
272272 n = Complex(r, sign == '+' ? i : -i)
273273 s = string(s1, r, s2, sign, s3, i, Im, s4)
274274 @test n === parse(Complex{Int}, s)
282282 @test n*parse(T,"1e-3") == parse(Complex{T}, string(s1, r, "e-3", s2, sign, s3, i, "e-3", Im, s4))
283283 end
284284 end
285 for r in (-1.0,-1e-9,Inf,-Inf,NaN), i in (-1.0,-1e-9,Inf,NaN)
286 n = Complex(r, sign == '+' ? i : -i)
287 s = lowercase(string(s1, r, s2, sign, s3, i, Im, s4))
288 @test n === parse(ComplexF64, s)
289 @test Complex(r) === parse(ComplexF64, string(s1, r, s2))
290 @test Complex(0,i) === parse(ComplexF64, string(s3, i, Im, s4))
291 end
285292 end
286293 @test parse(Complex{Float16}, "3.3+4i") === Complex{Float16}(3.3+4im)
287294 @test parse(Complex{Int}, SubString("xxxxxx1+2imxxxx", 7, 10)) === 1+2im
310317 @test eltype([tryparse(Float64, s) for s in String[]]) == Union{Nothing, Float64}
311318 @test eltype([tryparse(Complex{Int}, s) for s in String[]]) == Union{Nothing, Complex{Int}}
312319 end
320
321 @testset "inf and nan parsing" begin
322 for (v,vs) in ((NaN,"nan"), (Inf,"inf"), (Inf,"infinity")), sbefore in ("", " "), safter in ("", " "), sign in (+, -), case in (lowercase, uppercase)
323 s = case(string(sbefore, sign, vs, safter))
324 @test isequal(parse(Float64, s), sign(v))
325 end
326 end
743743 end
744744 end
745745
746 # issue #29936
747 let
748 load_path = mktempdir()
749 load_cache_path = mktempdir()
750 try
751 write(joinpath(load_path, "Foo29936.jl"),
752 """
753 module Foo29936
754 const global m = Val{nothing}()
755 const global h = Val{:hey}()
756 wab = [("a", m), ("b", h),]
757 end
758 """)
759 pushfirst!(LOAD_PATH, load_path)
760 pushfirst!(DEPOT_PATH, load_cache_path)
761 @eval using Foo29936
762 @test [("Plan", Foo29936.m), ("Plan", Foo29936.h),] isa Vector{Tuple{String,Val}}
763 finally
764 rm(load_path, recursive=true)
765 rm(load_cache_path, recursive=true)
766 end
767 end
746768
747769 end # !withenv
14051405 @test @inferred(z4 .+ z4) === z4
14061406 end
14071407
1408 @testset "Issue #30006" begin
1409 @test Base.Slice(Base.OneTo(5))[Int32(1)] == Int32(1)
1410 @test Base.Slice(Base.OneTo(3))[Int8(2)] == Int8(2)
1411 @test Base.Slice(1:10)[Int32(2)] == Int32(2)
1412 @test Base.Slice(1:10)[Int8(2)] == Int8(2)
1413 end
1414
1415 @testset "Issue #30006" begin
1416 @test Base.Slice(Base.OneTo(5))[Int32(1)] == Int32(1)
1417 @test Base.Slice(Base.OneTo(3))[Int8(2)] == Int8(2)
1418 @test Base.Slice(1:10)[Int32(2)] == Int32(2)
1419 @test Base.Slice(1:10)[Int8(2)] == Int8(2)
1420 end
1421
14081422 @testset "allocation of TwicePrecision call" begin
14091423 0:286.493442:360
14101424 0:286:360
159159 r = reinterpret(Int, vt)
160160 @test r == OffsetArray(reshape(1:8, 2, 2, 2), (0, offsetvt...))
161161 end
162
163 @testset "potentially aliased copies" begin
164 buffer = UInt8[1,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0]
165 mid = length(buffer) ÷ 2
166 x1 = reinterpret(Int64, @view buffer[1:mid])
167 x2 = reinterpret(Int64, @view buffer[mid+1:end])
168 x1 .= x2
169 @test x1 == x2 == [2]
170 @test x1[] === x2[] === Int64(2)
171 end
172
173 # Test 0-dimensional Arrays
174 A = zeros(UInt32)
175 B = reinterpret(Int32,A)
176 @test size(B) == ()
177 @test axes(B) == ()
178 B[] = Int32(5)
179 @test B[] === Int32(5)
180 @test A[] === UInt32(5)
612612 end
613613 end
614614
615 @testset "optimized union! with max_values" begin
616 # issue #30315
617 T = Union{Nothing, Bool}
618 @test Base.max_values(T) == 3
619 d = Set{T}()
620 union!(d, (nothing, true, false))
621 @test length(d) == 3
622 @test d == Set((nothing, true, false))
623 @test nothing in d
624 @test true in d
625 @test false in d
626
627 for X = (Int8, Int16, Int32, Int64)
628 @test Base.max_values(Union{Nothing, X}) == (sizeof(X) < sizeof(Int) ?
629 2^(8*sizeof(X)) + 1 :
630 typemax(Int))
631 end
632 # this does not account for non-empty intersections of the unioned types
633 @test Base.max_values(Union{Int8,Int16}) == 2^8 + 2^16
634 end
635
615636 struct OpenInterval{T}
616637 lower::T
617638 upper::T
300300 @test chomp("foo\r\n") == "foo"
301301 @test chomp("fo∀\r\n") == "fo∀"
302302 @test chomp("fo∀") == "fo∀"
303 @test chop("") == ""
303304 @test chop("fooε") == "foo"
304305 @test chop("foεo") == "foε"
305306 @test chop("∃∃∃∃") == "∃∃∃"