New upstream version 1.0.4+dfsg
Mo Zhou
5 years ago
39 | 39 | - gfortran-5 |
40 | 40 | - os: osx |
41 | 41 | env: ARCH="x86_64" |
42 | osx_image: xcode8 | |
42 | osx_image: xcode8.3 | |
43 | 43 | cache: ccache |
44 | 44 | branches: |
45 | 45 | only: |
66 | 66 | end |
67 | 67 | |
68 | 68 | 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)) | |
71 | 72 | max_values(::Type{Bool}) = 2 |
73 | max_values(::Type{Nothing}) = 1 | |
72 | 74 | |
73 | 75 | function union!(s::AbstractSet{T}, itr) where T |
74 | 76 | haslength(itr) && sizehint!(s, length(s) + length(itr)) |
433 | 433 | io = IOContext(io, :typeinfo => eltype(v), :compact => get(io, :compact, true)) |
434 | 434 | limited = get(io, :limit, false) |
435 | 435 | 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) | |
438 | 439 | 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) | |
440 | 441 | else |
441 | 442 | show_delim_array(io, v, opn, ",", cls, false) |
442 | 443 | end |
129 | 129 | return defssa |
130 | 130 | end |
131 | 131 | if isa(def.val, SSAValue) |
132 | if isa(defssa, OldSSAValue) && !already_inserted(compact, defssa) | |
132 | if is_old(compact, defssa) | |
133 | 133 | defssa = OldSSAValue(def.val.id) |
134 | 134 | else |
135 | 135 | defssa = def.val |
190 | 190 | collect(Iterators.filter(1:length(def.edges)) do n |
191 | 191 | isassigned(def.values, n) || return false |
192 | 192 | val = def.values[n] |
193 | if isa(defssa, OldSSAValue) && isa(val, SSAValue) | |
193 | if is_old(compact, defssa) && isa(val, SSAValue) | |
194 | 194 | val = OldSSAValue(val.id) |
195 | 195 | end |
196 | 196 | edge_typ = widenconst(compact_exprtype(compact, val)) |
200 | 200 | for n in possible_predecessors |
201 | 201 | pred = def.edges[n] |
202 | 202 | val = def.values[n] |
203 | if isa(defssa, OldSSAValue) && isa(val, SSAValue) | |
203 | if is_old(compact, defssa) && isa(val, SSAValue) | |
204 | 204 | val = OldSSAValue(val.id) |
205 | 205 | end |
206 | 206 | if isa(val, AnySSAValue) |
280 | 280 | end |
281 | 281 | if is_tuple_call(compact.ir, def) && isa(field, Int) && 1 <= field < length(def.args) |
282 | 282 | lifted = def.args[1+field] |
283 | if isa(leaf, OldSSAValue) && isa(lifted, SSAValue) | |
283 | if is_old(compact, leaf) && isa(lifted, SSAValue) | |
284 | 284 | lifted = OldSSAValue(lifted.id) |
285 | 285 | end |
286 | 286 | if isa(lifted, GlobalRef) || isa(lifted, Expr) |
319 | 319 | compact[leaf] = def |
320 | 320 | end |
321 | 321 | lifted = def.args[1+field] |
322 | if isa(leaf, OldSSAValue) && isa(lifted, SSAValue) | |
322 | if is_old(compact, leaf) && isa(lifted, SSAValue) | |
323 | 323 | lifted = OldSSAValue(lifted.id) |
324 | 324 | end |
325 | 325 | if isa(lifted, GlobalRef) || isa(lifted, Expr) |
338 | 338 | # N.B.: This can be a bit dangerous because it can lead to |
339 | 339 | # infinite loops if we accidentally insert a node just ahead |
340 | 340 | # 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)) | |
342 | 342 | (isa(typ, DataType) && (!typ.abstract)) || return nothing |
343 | 343 | @assert !typ.mutable |
344 | 344 | # If there's the potential for an undefref error on access, we cannot insert a getfield |
424 | 424 | need_argupdate::Bool |
425 | 425 | end |
426 | 426 | |
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 | ||
427 | 433 | function perform_lifting!(compact::IncrementalCompact, |
428 | 434 | visited_phinodes::Vector{Any}, @nospecialize(cache_key), |
429 | 435 | lifting_cache::IdDict{Pair{AnySSAValue, Any}, AnySSAValue}, |
454 | 460 | isassigned(old_node.values, i) || continue |
455 | 461 | val = old_node.values[i] |
456 | 462 | 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) | |
458 | 464 | val = OldSSAValue(val.id) |
459 | 465 | end |
460 | 466 | if isa(val, Union{NewSSAValue, SSAValue, OldSSAValue}) |
687 | 693 | compact[idx] = val === nothing ? nothing : val.x |
688 | 694 | end |
689 | 695 | |
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). | |
692 | 701 | used_ssas = copy(compact.used_ssas) |
693 | ir = finish(compact) | |
702 | simple_dce!(compact) | |
703 | ir = complete(compact) | |
694 | 704 | # Now go through any mutable structs and see which ones we can eliminate |
695 | 705 | for (idx, (intermediaries, defuse)) in defuses |
696 | 706 | intermediaries = collect(intermediaries) |
26 | 26 | """ |
27 | 27 | deepcopy(x) = deepcopy_internal(x, IdDict())::typeof(x) |
28 | 28 | |
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}, | |
30 | 30 | stackdict::IdDict) = x |
31 | 31 | deepcopy_internal(x::Tuple, stackdict::IdDict) = |
32 | 32 | ntuple(i->deepcopy_internal(x[i], stackdict), length(x)) |
1093 | 1093 | |
1094 | 1094 | @inline peek(s::Stateful, sentinel=nothing) = s.nextvalstate !== nothing ? s.nextvalstate[1] : sentinel |
1095 | 1095 | @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) | |
1098 | 1097 | 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) | |
1100 | 1099 | length(s::Stateful) = length(s.itr) - s.taken |
1101 | 1100 | |
1102 | 1101 | end |
308 | 308 | end |
309 | 309 | |
310 | 310 | 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") | |
312 | 312 | x = tryparse_internal(T, s, i, iᵢ-1, raise) |
313 | 313 | x === nothing && return nothing |
314 | 314 | return Complex{T}(zero(x),x) |
607 | 607 | @_inline_meta |
608 | 608 | ret = convert(T, first(v) + (i - 1)*step_hp(v)) |
609 | 609 | 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))) | |
612 | 612 | @boundscheck ((i > 0) & ok) || throw_boundserror(v, i) |
613 | 613 | ret |
614 | 614 | end |
32 | 32 | isbitstype(T) || throwbits(S, T, T) |
33 | 33 | isbitstype(S) || throwbits(S, T, S) |
34 | 34 | (N != 0 || sizeof(T) == sizeof(S)) || throwsize0(S, T) |
35 | ax1 = axes(a)[1] | |
36 | 35 | if N != 0 && sizeof(S) != sizeof(T) |
36 | ax1 = axes(a)[1] | |
37 | 37 | dim = length(ax1) |
38 | 38 | rem(dim*sizeof(S),sizeof(T)) == 0 || thrownonint(S, T, dim) |
39 | 39 | first(ax1) == 1 || throwaxes1(S, T, ax1) |
67 | 67 | |
68 | 68 | parent(a::ReinterpretArray) = a.parent |
69 | 69 | dataids(a::ReinterpretArray) = dataids(a.parent) |
70 | unaliascopy(a::ReinterpretArray{T}) where {T} = reinterpret(T, unaliascopy(a.parent)) | |
70 | 71 | |
71 | 72 | function size(a::ReinterpretArray{T,N,S} where {N}) where {T,S} |
72 | 73 | psize = size(a.parent) |
73 | 74 | size1 = div(psize[1]*sizeof(S), sizeof(T)) |
74 | 75 | tuple(size1, tail(psize)...) |
75 | 76 | end |
77 | size(a::ReinterpretArray{T,0}) where {T} = () | |
76 | 78 | |
77 | 79 | function axes(a::ReinterpretArray{T,N,S} where {N}) where {T,S} |
78 | 80 | paxs = axes(a.parent) |
80 | 82 | size1 = div(l*sizeof(S), sizeof(T)) |
81 | 83 | tuple(oftype(paxs[1], f:f+size1-1), tail(paxs)...) |
82 | 84 | end |
85 | axes(a::ReinterpretArray{T,0}) where {T} = () | |
83 | 86 | |
84 | 87 | elsize(::Type{<:ReinterpretArray{T}}) where {T} = sizeof(T) |
85 | 88 | unsafe_convert(::Type{Ptr{T}}, a::ReinterpretArray{T,N,S} where N) where {T,S} = Ptr{T}(unsafe_convert(Ptr{S},a.parent)) |
95 | 95 | ``` |
96 | 96 | """ |
97 | 97 | function chop(s::AbstractString; head::Integer = 0, tail::Integer = 1) |
98 | if isempty(s) | |
99 | return SubString(s) | |
100 | end | |
98 | 101 | SubString(s, nextind(s, firstindex(s), head), prevind(s, lastindex(s), tail)) |
99 | 102 | end |
100 | 103 |
Binary diff not shown
6 | 6 | UNWIND_VER = 1.1-julia2 |
7 | 7 | OSXUNWIND_VER = 0.0.5 |
8 | 8 | GMP_VER = 6.1.2 |
9 | MPFR_VER = 4.0.1 | |
9 | MPFR_VER = 4.0.2 | |
10 | 10 | PATCHELF_VER = 0.9 |
11 | 11 | MBEDTLS_VER = 2.6.0 |
12 | 12 | CURL_VER = 7.56.0 |
14 | 14 | # Specify the version of the Mozilla CA Certificate Store to obtain. |
15 | 15 | # The versions of cacert.pem are identified by the date (YYYY-MM-DD) of their changes. |
16 | 16 | # 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 | 4e0bcbf65c67c86b1604e103db173d77 |
0 | 95022a2aee8bca4b8e1ce65b5e5840209cd7adb7d048a647c9501e15e0ebd37fb4e4a95e707a5ec001893789ae841e3300a615f8e21a711694fc288777eed726 |
0 | 498ed1792ccd8e3a895edf290d8066ca |
0 | 83143d69e27da5fa58e5fa1ceab41aff7af242eea5399d4512c381d12fd90c7a3106db2a84af1f9a33c5bb917e7f05208310f34fd3b182595b581dc8070e3491 |
0 | fccbe6cec7a76e3351ad32e305184787 |
0 | 01faebab60b49a30736e0c88b713999f48c99b425889f7df9bbb80eb91367a6f26f20befdf8ac72b8d77659b143b7b37f91ad7dac5fde37c1d621fc663003687 |
0 | bcf01c3fa49a1684edc2d637ad7e03d6 |
0 | ae4c798ae5c13ad1574646896665ccd1f7d91e64573a23662ce7016b00109c1c351013856c25bf12284d9c3996ca3b828506825e50fcb059969adc02a96c06f8 |
0 | d251ef0efecff323b6f570cc737d3411 |
0 | ae7535cf8f70e7c837e80365cd9ee7c4040d45e952871a3e5c8f1b71bd8eb2d96babb07fa4c5d66a83bb45960728ef8dbba30ab9a6387a68cf815a84cdae8795 |
0 | c1674fc0a5edcde188bdf7d6d14063cfb4f1259b9eaf39d0081f7176e9921ca0af1b12b7aba1a9560d9f2d5f37329d22bc7b82f13421d91d83114b439bc60dcc |
0 | 6d8a8bb46fe09ff44e21cdbf84f5cdac |
0 | 18bb3a87123d02b7537bc298d41bdbb33e58b8c196cc4040578e3b470e86c6c89e1bd8ab8b3919d106fe5b86922ef8999dc1aba7c521ee90a69f690be288a30d |
20 | 20 | cd $(dir $@) && patch < $(SRCDIR)/patches/gmp-exception.patch |
21 | 21 | echo 1 > $@ |
22 | 22 | |
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 | |
24 | 30 | mkdir -p $(dir $@) |
25 | 31 | cd $(dir $@) && \ |
26 | 32 | $(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 |
64 | 64 | LLVM_CPPFLAGS += $(CPPFLAGS) |
65 | 65 | LLVM_LDFLAGS += $(LDFLAGS) |
66 | 66 | 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))" | |
68 | 68 | ifeq ($(USE_POLLY_ACC),1) |
69 | 69 | LLVM_CMAKE += -DPOLLY_ENABLE_GPGPU_CODEGEN=ON |
70 | 70 | 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 |
42 | 42 | |
43 | 43 | #include "julia.h" |
44 | 44 | #include "julia_internal.h" |
45 | #include "processor.h" | |
45 | 46 | |
46 | 47 | #ifdef _CPU_AARCH64_ |
47 | 48 | # include <sys/auxv.h> |
332 | 333 | # else |
333 | 334 | static crc32c_func_t crc32c_dispatch(unsigned long hwcap) |
334 | 335 | { |
335 | if (hwcap & HWCAP_CRC32) | |
336 | if (hwcap & (1 << JL_AArch64_crc)) | |
336 | 337 | return crc32c_armv8; |
337 | 338 | return jl_crc32c_sw; |
338 | 339 | } |
1100 | 1100 | for (size_t i = 0; i < sysimg_fptrs.nclones; i++) { |
1101 | 1101 | if (diff == sysimg_fptrs.clone_offsets[i]) { |
1102 | 1102 | 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]; | |
1104 | 1105 | break; |
1105 | 1106 | } |
1106 | 1107 | } |
627 | 627 | { |
628 | 628 | // GC safe |
629 | 629 | // Get the host information |
630 | std::string TripleName = sys::getDefaultTargetTriple(); | |
631 | Triple TheTriple(Triple::normalize(TripleName)); | |
630 | Triple TheTriple(sys::getProcessTriple()); | |
632 | 631 | |
633 | 632 | const auto &target = jl_get_llvm_disasm_target(); |
634 | 633 | const auto &cpu = target.first; |
635 | 634 | const auto &features = target.second; |
636 | 635 | |
637 | 636 | std::string err; |
638 | const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, err); | |
637 | const Target *TheTarget = TargetRegistry::lookupTarget(TheTriple.str(), err); | |
639 | 638 | |
640 | 639 | // Set up required helpers and streamer |
641 | 640 | std::unique_ptr<MCStreamer> Streamer; |
642 | 641 | SourceMgr SrcMgr; |
643 | 642 | |
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())); | |
645 | 644 | assert(MAI && "Unable to create target asm info!"); |
646 | 645 | |
647 | std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName)); | |
646 | std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TheTriple.str())); | |
648 | 647 | assert(MRI && "Unable to create target register info!"); |
649 | 648 | |
650 | 649 | std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo()); |
658 | 657 | |
659 | 658 | // Set up Subtarget and Disassembler |
660 | 659 | std::unique_ptr<MCSubtargetInfo> |
661 | STI(TheTarget->createMCSubtargetInfo(TripleName, cpu, features)); | |
660 | STI(TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features)); | |
662 | 661 | std::unique_ptr<MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI, Ctx)); |
663 | 662 | 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(); | |
666 | 664 | return; |
667 | 665 | } |
668 | 666 | unsigned OutputAsmVariant = 0; // ATT or Intel-style assembly |
669 | 667 | |
670 | if (strcmp(asm_variant, "intel")==0) { | |
668 | if (strcmp(asm_variant, "intel") == 0) { | |
671 | 669 | OutputAsmVariant = 1; |
672 | 670 | } |
673 | 671 | bool ShowEncoding = false; |
254 | 254 | return 0; |
255 | 255 | if (module_in_worklist(p->name->module)) |
256 | 256 | return 0; |
257 | if (p->name->wrapper != (jl_value_t*)p0) { | |
257 | if (jl_unwrap_unionall(p->name->wrapper) != (jl_value_t*)p) { | |
258 | 258 | if (!type_recursively_external(p)) |
259 | 259 | return 0; |
260 | 260 | } |
742 | 742 | else if (jl_is_unionall(v)) { |
743 | 743 | write_uint8(s->s, TAG_UNIONALL); |
744 | 744 | 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 && | |
746 | 746 | !module_in_worklist(d->name->module)) { |
747 | 747 | write_uint8(s->s, 1); |
748 | 748 | jl_serialize_value(s, d->name->module); |
32 | 32 | JL_DLLEXPORT size_t jl_get_tls_world_age(void) |
33 | 33 | { |
34 | 34 | 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 | } | |
57 | 35 | } |
58 | 36 | |
59 | 37 | /// ----- Handling for Julia callbacks ----- /// |
2199 | 2177 | return (jl_value_t*)entry; |
2200 | 2178 | } |
2201 | 2179 | |
2180 | jl_value_t *jl_gf_invoke_by_method(jl_method_t *method, jl_value_t **args, size_t nargs); | |
2181 | ||
2202 | 2182 | // invoke() |
2203 | 2183 | // this does method dispatch with a set of types to match other than the |
2204 | 2184 | // types of the actual arguments. this means it sometimes does NOT call the |
2211 | 2191 | jl_value_t *jl_gf_invoke(jl_value_t *types0, jl_value_t **args, size_t nargs) |
2212 | 2192 | { |
2213 | 2193 | size_t world = jl_get_ptls_states()->world_age; |
2214 | jl_svec_t *tpenv = jl_emptysvec; | |
2215 | jl_tupletype_t *tt = NULL; | |
2216 | 2194 | jl_value_t *types = NULL; |
2217 | JL_GC_PUSH3(&types, &tpenv, &tt); | |
2195 | JL_GC_PUSH1(&types); | |
2218 | 2196 | jl_value_t *gf = args[0]; |
2219 | 2197 | types = jl_argtype_with_function(gf, types0); |
2220 | jl_methtable_t *mt = jl_gf_mtable(gf); | |
2221 | 2198 | jl_typemap_entry_t *entry = (jl_typemap_entry_t*)jl_gf_invoke_lookup(types, world); |
2222 | 2199 | |
2223 | 2200 | if ((jl_value_t*)entry == jl_nothing) { |
2227 | 2204 | |
2228 | 2205 | // now we have found the matching definition. |
2229 | 2206 | // 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; | |
2232 | 2214 | jl_method_instance_t *mfunc = NULL; |
2233 | 2215 | 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); | |
2234 | 2220 | if (method->invokes.unknown != NULL) |
2235 | 2221 | tm = jl_typemap_assoc_exact(method->invokes, args, nargs, jl_cachearg_offset(mt), world); |
2236 | 2222 | if (tm) { |
2247 | 2233 | if (method->invokes.unknown == NULL) |
2248 | 2234 | method->invokes.unknown = jl_nothing; |
2249 | 2235 | |
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); | |
2251 | 2237 | JL_UNLOCK(&method->writelock); |
2252 | 2238 | } |
2253 | 2239 | JL_GC_POP(); |
2300 | 2286 | JL_GC_POP(); |
2301 | 2287 | JL_UNLOCK(&method->writelock); |
2302 | 2288 | 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 | } | |
2303 | 2316 | } |
2304 | 2317 | |
2305 | 2318 | // Return value is rooted globally |
2394 | 2407 | closure->max_valid = ml->max_world; |
2395 | 2408 | } |
2396 | 2409 | } |
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; | |
2397 | 2416 | // a method is shadowed if type <: S <: m->sig where S is the |
2398 | 2417 | // signature of another applicable method |
2399 | 2418 | /* |
395 | 395 | (vararg (let ((l (if (null? pargl) '() (last pargl)))) |
396 | 396 | (if (or (vararg? l) (varargexpr? l)) |
397 | 397 | (list l) '()))) |
398 | ;; positional args with vararg | |
399 | (pargl-all pargl) | |
398 | 400 | ;; positional args without vararg |
399 | 401 | (pargl (if (null? vararg) pargl (butlast pargl))) |
400 | 402 | ;; positional args with everything required; for use by the core function |
423 | 425 | (filter nospecialize-meta? kargl))) |
424 | 426 | ;; body statements |
425 | 427 | (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)) | |
433 | 429 | (keyword-sparams |
434 | 430 | (filter (lambda (s) |
435 | 431 | (not (any (lambda (p) (eq? (car p) (car s))) |
461 | 457 | |
462 | 458 | ;; call with no keyword args |
463 | 459 | ,(method-def-expr- |
464 | name positional-sparams (append pargl vararg) | |
460 | name positional-sparams pargl-all | |
465 | 461 | `(block |
466 | 462 | ,@(without-generated prologue) |
467 | 463 | ,(let (;; call mangled(vals..., [rest_kw,] pargs..., [vararg]...) |
477 | 473 | |
478 | 474 | ;; call with unsorted keyword args. this sorts and re-dispatches. |
479 | 475 | ,(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 | |
483 | 477 | `((|::| |
484 | 478 | ;; if there are optional positional args, we need to be able to reference the function name |
485 | 479 | ,(if (any kwarg? pargl) (gensy) UNUSED) |
2997 | 2991 | (kill)) |
2998 | 2992 | (cdr e))) |
2999 | 2993 | (else |
3000 | (mark-used e) | |
2994 | (if (eq? (car e) '=) | |
2995 | (visit (caddr e)) | |
2996 | (mark-used e)) | |
3001 | 2997 | (if (and (or (eq? (car e) '=) |
3002 | 2998 | (and (eq? (car e) 'method) (length> e 2))) |
3003 | 2999 | (has? unused (cadr e))) |
206 | 206 | MDNode *n = L->getLoopID(); |
207 | 207 | if (!n) { |
208 | 208 | // 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)); | |
211 | 212 | L->setLoopID(n); |
212 | 213 | } |
213 | 214 |
1014 | 1014 | for (i = 0; i < sysimg_fvars_max; i++) { |
1015 | 1015 | uintptr_t val = (uintptr_t)&linfos[i]; |
1016 | 1016 | uint32_t offset = load_uint32(&val); |
1017 | linfos[i] = NULL; | |
1017 | 1018 | if (offset != 0) { |
1018 | 1019 | int specfunc = 1; |
1019 | 1020 | if (offset & ((uintptr_t)1 << (8 * sizeof(uint32_t) - 1))) { |
117 | 117 | |
118 | 118 | decimal_point_pos = NULL; |
119 | 119 | |
120 | p = nptr; | |
121 | ||
122 | /* parse leading spaces */ | |
123 | while (isspace((unsigned char)*p)) { | |
124 | p++; | |
125 | } | |
126 | ||
120 | 127 | /* 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) | |
123 | 130 | return val; |
124 | 131 | |
125 | 132 | /* Set errno to zero, so that we can distinguish zero results |
129 | 136 | /* We process the optional sign manually, then pass the remainder to |
130 | 137 | the system strtod. This ensures that the result of an underflow |
131 | 138 | has the correct sign. */ |
132 | p = nptr; | |
133 | ||
134 | /* parse leading spaces */ | |
135 | while (isspace((unsigned char)*p)) { | |
136 | p++; | |
137 | } | |
138 | 139 | |
139 | 140 | /* Process leading sign, if present */ |
140 | 141 | if (*p == '-') { |
134 | 134 | extract_imports!(imports, x) = imports |
135 | 135 | function extract_imports!(imports, ex::Expr) |
136 | 136 | 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) | |
145 | 138 | elseif Meta.isexpr(ex, :let) |
146 | 139 | extract_imports!(imports, ex.args[2]) |
147 | 140 | 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) | |
150 | 143 | end |
151 | 144 | end |
152 | 145 | return imports |
153 | 146 | end |
154 | extract_imports(x) = extract_imports!(Symbol[], x) | |
147 | extract_imports(x) = extract_imports!(Any[], x) | |
155 | 148 | |
156 | 149 | """ |
157 | 150 | @everywhere [procs()] expr |
182 | 175 | end |
183 | 176 | |
184 | 177 | macro everywhere(procs, ex) |
185 | imps = [Expr(:import, m) for m in extract_imports(ex)] | |
178 | imps = extract_imports(ex) | |
186 | 179 | return quote |
187 | 180 | $(isempty(imps) ? nothing : Expr(:toplevel, imps...)) # run imports locally first |
188 | 181 | let ex = $(Expr(:quote, ex)), procs = $(esc(procs)) |
7 | 7 | include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl")) |
8 | 8 | |
9 | 9 | @test Distributed.extract_imports(:(begin; import Foo, Bar; let; using Baz; end; end)) == |
10 | [:Foo, :Bar, :Baz] | |
10 | Any[:(import Foo, Bar), :(using Baz)] | |
11 | 11 | |
12 | 12 | # Test a few "remote" invocations when no workers are present |
13 | 13 | @test remote(myid)() == 1 |
167 | 167 | |
168 | 168 | function rmul!(A::AbstractMatrix, D::Diagonal) |
169 | 169 | @assert !has_offset_axes(A) |
170 | A .= A .* transpose(D.diag) | |
170 | A .= A .* permutedims(D.diag) | |
171 | 171 | return A |
172 | 172 | end |
173 | 173 | |
255 | 255 | |
256 | 256 | function lmul!(adjA::Adjoint{<:Any,<:Diagonal}, B::AbstractMatrix) |
257 | 257 | A = adjA.parent |
258 | return lmul!(conj(A.diag), B) | |
258 | return lmul!(adjoint(A), B) | |
259 | 259 | end |
260 | 260 | function lmul!(transA::Transpose{<:Any,<:Diagonal}, B::AbstractMatrix) |
261 | 261 | A = transA.parent |
262 | return lmul!(A.diag, B) | |
262 | return lmul!(transpose(A), B) | |
263 | 263 | end |
264 | 264 | |
265 | 265 | function rmul!(A::AbstractMatrix, adjB::Adjoint{<:Any,<:Diagonal}) |
266 | 266 | B = adjB.parent |
267 | return rmul!(A, conj(B.diag)) | |
267 | return rmul!(A, adjoint(B)) | |
268 | 268 | end |
269 | 269 | function rmul!(A::AbstractMatrix, transB::Transpose{<:Any,<:Diagonal}) |
270 | 270 | B = transB.parent |
271 | return rmul!(A, B.diag) | |
271 | return rmul!(A, transpose(B)) | |
272 | 272 | end |
273 | 273 | |
274 | 274 | # Get ambiguous method if try to unify AbstractVector/AbstractMatrix here using AbstractVecOrMat |
507 | 507 | *(x::Adjoint{<:Any,<:AbstractVector}, D::Diagonal) = Adjoint(map((t,s) -> t'*s, D.diag, parent(x))) |
508 | 508 | *(x::Adjoint{<:Any,<:AbstractVector}, D::Diagonal, y::AbstractVector) = |
509 | 509 | 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))) | |
511 | 511 | *(x::Transpose{<:Any,<:AbstractVector}, D::Diagonal, y::AbstractVector) = |
512 | 512 | 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 | |
514 | 513 | |
515 | 514 | function cholesky!(A::Diagonal, ::Val{false} = Val(false); check::Bool = true) |
516 | 515 | info = 0 |
440 | 440 | fullBB = copyto!(Matrix{Matrix{T}}(undef, 2, 2), BB) |
441 | 441 | for (transform1, transform2) in ((identity, identity), |
442 | 442 | (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)) | |
444 | 446 | @test *(transform1(D), transform2(B))::typeof(D) ≈ *(transform1(Matrix(D)), transform2(Matrix(B))) atol=2 * eps() |
445 | 447 | @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)) | |
446 | 456 | end |
447 | 457 | end |
448 | 458 | end |
453 | 463 | end |
454 | 464 | |
455 | 465 | @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 | |
460 | 476 | end |
461 | 477 | |
462 | 478 | @testset "Triangular division by Diagonal #27989" begin |
0 | 0 | PKG_BRANCH = master |
1 | PKG_SHA1 = 93b6d6de857dc88e665d2c64397852ab9701ba24 | |
1 | PKG_SHA1 = 1609a05aee5d5960670738d8d834d91235bd6b1e |
513 | 513 | # jump forward to the end of the inlining chain |
514 | 514 | # avoiding an extra (slow) lookup of `ip` in `lidict` |
515 | 515 | # and an extra chain of them in `down` |
516 | # note that we may even have this === parent (if we're ignoring this frame ip) | |
516 | 517 | this = builder_value[fastkey] |
517 | 518 | let this = this |
518 | 519 | while this !== parent |
531 | 532 | frame = (frames isa Vector ? frames[i] : frames) |
532 | 533 | !C && frame.from_c && continue |
533 | 534 | key = (T === UInt64 ? ip : frame) |
534 | down = parent.down | |
535 | this = get!(down, key) do | |
535 | this = get!(parent.down, key) do | |
536 | 536 | return StackFrameTree{T}() |
537 | 537 | end |
538 | 538 | this.frame = frame |
352 | 352 | function get_value_getfield(ex::Expr, fn) |
353 | 353 | # Example :((top(getfield))(Base,:max)) |
354 | 354 | 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) | |
356 | 356 | return get_value_getfield(ex.args[3], val) #Look up max in Base and returns the function if found. |
357 | 357 | end |
358 | 358 | get_value_getfield(sym, fn) = get_value(sym, fn) |
406 | 406 | elseif sym.head === :ref |
407 | 407 | # some simple cases of `expand` |
408 | 408 | 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 | |
410 | 410 | return try_get_type(Expr(:call, GlobalRef(Core, :getfield), sym.args...), fn) |
411 | 411 | end |
412 | 412 | return (Any, false) |
431 | 431 | args_ex = Any[] |
432 | 432 | func, found = get_value(ex_org.args[1], context_module) |
433 | 433 | !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 | ||
438 | 449 | out = Completion[] |
439 | 450 | t_in = Tuple{Core.Typeof(func), args_ex...} # Input types |
440 | 451 | na = length(args_ex)+1 |
609 | 620 | |
610 | 621 | # Make sure that only bslash_completions is working on strings |
611 | 622 | inc_tag==:string && return String[], 0:-1, false |
612 | ||
613 | 623 | if inc_tag == :other && should_method_complete(partial) |
614 | 624 | frange, method_name_end = find_start_brace(partial) |
615 | 625 | 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 | |
618 | 633 | end |
619 | 634 | elseif inc_tag == :comment |
620 | 635 | return Completion[], 0:-1, false |
20 | 20 | |
21 | 21 | function _helpmode(io::IO, line::AbstractString) |
22 | 22 | line = strip(line) |
23 | x = Meta.parse(line, raise = false, depwarn = false) | |
23 | 24 | expr = |
24 | if haskey(keywords, Symbol(line)) | |
25 | if haskey(keywords, Symbol(line)) || isexpr(x, :error) || isexpr(x, :invalid) | |
25 | 26 | # Docs for keywords must be treated separately since trying to parse a single |
26 | 27 | # keyword such as `function` would throw a parse error due to the missing `end`. |
27 | 28 | Symbol(line) |
28 | 29 | else |
29 | x = Meta.parse(line, raise = false, depwarn = false) | |
30 | 30 | # Retrieving docs for macros requires us to make a distinction between the text |
31 | 31 | # `@macroname` and `@macroname()`. These both parse the same, but are used by |
32 | 32 | # the docsystem to return different results. The first returns all documentation |
971 | 971 | @test Base.eval(REPL._helpmode(buf, line)) isa Union{Markdown.MD,Nothing} |
972 | 972 | end |
973 | 973 | |
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 | ||
974 | 980 | # PR #27562 |
975 | 981 | fake_repl() do stdin_write, stdout_read, repl |
976 | 982 | repltask = @async begin |
959 | 959 | @test s[r] == "y" |
960 | 960 | end |
961 | 961 | |
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 | ||
962 | 972 | let s = "Base.return_types(getin" |
963 | 973 | c, r = test_complete_context(s) |
964 | 974 | @test "getindex" in c |
976 | 986 | @test !res |
977 | 987 | @test c[1] == string(first(methods(Main.CompletionFoo.test, Tuple{Int, Int}))) |
978 | 988 | @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 | |
979 | 997 | @test r == 1:4 |
980 | 998 | @test s[r] == "test" |
981 | 999 | end |
8 | 8 | 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." |
9 | 9 | so_many_as_array = repeat([0x61], 1000000) |
10 | 10 | so_many_as_tuple = ntuple((i) -> 0x61, 1000000) |
11 | file = ".sha" # Subject to change | |
11 | tempdir = mktempdir() | |
12 | file = joinpath(tempdir, ".sha") | |
12 | 13 | fIO = open(file, "w") |
13 | 14 | write(fIO, '\0') |
14 | 15 | close(fIO) |
273 | 274 | # test error if eltype of input is not UInt8 |
274 | 275 | for f in sha_funcs |
275 | 276 | global nerrors |
277 | data = UInt32[0x23467, 0x324775] | |
276 | 278 | 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 | |
282 | 290 | end |
283 | 291 | |
284 | 292 | # Clean up the I/O mess |
285 | 293 | rm(file) |
294 | rm(tempdir) | |
286 | 295 | |
287 | 296 | if nerrors == 0 |
288 | 297 | VERBOSE && println("ALL OK") |
382 | 382 | vals, ks, rows = _fusedupdate_all(rowsentinel, activerow, rows, ks, stopks, As) |
383 | 383 | Cx = f(vals...) |
384 | 384 | 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)))) | |
386 | 386 | storedinds(C)[Ck] = activerow |
387 | 387 | storedvals(C)[Ck] = Cx |
388 | 388 | Ck += 1 |
1557 | 1557 | sparse(s::UniformScaling, m::Integer, n::Integer) = sparse(s, Dims((m, n))) |
1558 | 1558 | |
1559 | 1559 | # 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 | |
1562 | 1569 | |
1563 | 1570 | # 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 | |
1566 | 1576 | imag(A::SparseMatrixCSC{Tv,Ti}) where {Tv<:Real,Ti} = spzeros(Tv, Ti, A.m, A.n) |
1567 | 1577 | |
1568 | 1578 | ## Binary arithmetic and boolean operators |
1967 | 1977 | return SparseMatrixCSC(m, nJ, colptrS, rowvalS, nzvalS) |
1968 | 1978 | end |
1969 | 1979 | |
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) | |
1972 | 1982 | |
1973 | 1983 | function getindex(A::SparseMatrixCSC{Tv,Ti}, I::AbstractRange, J::AbstractVector) where {Tv,Ti<:Integer} |
1974 | 1984 | @assert !has_offset_axes(A, I, J) |
631 | 631 | @test minimum(sparse([1, 2], [1, 2], ones(Int32, 2)), dims = 1) isa Matrix |
632 | 632 | end |
633 | 633 | |
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 | ||
634 | 644 | end # module |
89 | 89 | @test_throws DimensionMismatch map(|, sqrboolmat, colboolmat) |
90 | 90 | @test_throws DimensionMismatch map(xor, sqrboolmat, colboolmat) |
91 | 91 | end |
92 | end | |
93 | ||
94 | @testset "Issue #30006" begin | |
95 | SparseMatrixCSC{Float64,Int32}(spzeros(3,3))[:, 1] == [1, 2, 3] | |
92 | 96 | end |
93 | 97 | |
94 | 98 | @testset "concatenation tests" begin |
707 | 711 | ss116 = sparse(aa116) |
708 | 712 | |
709 | 713 | @test ss116[:,:] == copy(ss116) |
714 | ||
715 | @test convert(SparseMatrixCSC{Float32,Int32}, sd116)[2:5,:] == convert(SparseMatrixCSC{Float32,Int32}, sd116[2:5,:]) | |
710 | 716 | |
711 | 717 | # range indexing |
712 | 718 | @test Array(ss116[i,:]) == aa116[i,:] |
2306 | 2312 | @test m2.module == SparseArrays |
2307 | 2313 | end |
2308 | 2314 | |
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 | ||
2309 | 2327 | end # module |
3 | 3 | [deps] |
4 | 4 | Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" |
5 | 5 | LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" |
6 | Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | |
6 | 7 | SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" |
7 | 8 | |
8 | 9 | [extras] |
10 | DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" | |
11 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | |
12 | Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | |
9 | 13 | 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" | |
13 | 14 | |
14 | 15 | [targets] |
15 | 16 | test = ["Test", "Random", "DelimitedFiles", "Serialization"] |
9 | 9 | |
10 | 10 | using SparseArrays |
11 | 11 | import SparseArrays: nnz |
12 | ||
13 | import Serialization: AbstractSerializer, deserialize | |
12 | 14 | |
13 | 15 | import ..increment, ..increment!, ..decrement, ..decrement! |
14 | 16 | |
191 | 193 | F.numeric != C_NULL && print(io, '\n', F.numeric) |
192 | 194 | end |
193 | 195 | |
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 | ||
194 | 212 | ## Wrappers for UMFPACK functions |
195 | 213 | |
196 | 214 | # generate the name of the C function according to the value and integer types |
0 | 0 | # This file is a part of Julia. License is MIT: https://julialang.org/license |
1 | 1 | |
2 | 2 | using SuiteSparse: increment! |
3 | using Serialization | |
3 | 4 | using LinearAlgebra: Adjoint, Transpose, SingularException |
4 | 5 | |
5 | 6 | @testset "UMFPACK wrappers" begin |
175 | 176 | end |
176 | 177 | end |
177 | 178 | |
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 | ||
178 | 191 | end |
1820 | 1820 | sol |
1821 | 1821 | end |
1822 | 1822 | @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] | |
1823 | 1832 | |
1824 | 1833 | # issue #27316 - inference shouldn't hang on these |
1825 | 1834 | f27316(::Vector) = nothing |
2067 | 2076 | val |
2068 | 2077 | end |
2069 | 2078 | @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 |
83 | 83 | @test c[1] === c[2] |
84 | 84 | end |
85 | 85 | |
86 | # issue #30911 | |
87 | @test deepcopy(Array{Int,N} where N) == Array{Int,N} where N | |
88 | ||
86 | 89 | # issue #14027 |
87 | 90 | struct Nullable14027{T} |
88 | 91 | hasvalue::Bool |
2430 | 2430 | const T24460 = Tuple{T,T} where T |
2431 | 2431 | g24460() = invoke(f24460, T24460, 1, 2) |
2432 | 2432 | @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 | |
2433 | 2447 | |
2434 | 2448 | call_lambda1() = (()->x)(1) |
2435 | 2449 | call_lambda2() = ((x)->x)() |
548 | 548 | @test ps isa Iterators.Pairs |
549 | 549 | @test collect(ps) == [1 => :a, 2 => :b] |
550 | 550 | 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 |
116 | 116 | @test kwf7(1.5;k=2.5) === Float64 |
117 | 117 | @test_throws MethodError kwf7(1.5) |
118 | 118 | @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) | |
119 | 130 | end |
120 | 131 | # try to confuse it with quoted symbol |
121 | 132 | kwf8(x::MIME{:T};k::T=0) where {T} = 0 |
202 | 202 | cmp_showf(Base.print_matrix, io, OffsetArray(rand(5,10^3), (10,-9))) # rows fit |
203 | 203 | cmp_showf(Base.print_matrix, io, OffsetArray(rand(10^3,10^3), (10,-9))) # neither fits |
204 | 204 | 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 | ||
205 | 207 | targets1 = ["0-dimensional $OAs_name.OffsetArray{Float64,0,Array{Float64,0}}:\n1.0", |
206 | 208 | "$OAs_name.OffsetArray{Float64,1,Array{Float64,1}} with indices 2:2:\n 1.0", |
207 | 209 | "$OAs_name.OffsetArray{Float64,2,Array{Float64,2}} with indices 2:2×3:3:\n 1.0", |
267 | 267 | |
268 | 268 | # parsing complex numbers (#22250) |
269 | 269 | @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), | |
272 | 272 | n = Complex(r, sign == '+' ? i : -i) |
273 | 273 | s = string(s1, r, s2, sign, s3, i, Im, s4) |
274 | 274 | @test n === parse(Complex{Int}, s) |
282 | 282 | @test n*parse(T,"1e-3") == parse(Complex{T}, string(s1, r, "e-3", s2, sign, s3, i, "e-3", Im, s4)) |
283 | 283 | end |
284 | 284 | 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 | |
285 | 292 | end |
286 | 293 | @test parse(Complex{Float16}, "3.3+4i") === Complex{Float16}(3.3+4im) |
287 | 294 | @test parse(Complex{Int}, SubString("xxxxxx1+2imxxxx", 7, 10)) === 1+2im |
310 | 317 | @test eltype([tryparse(Float64, s) for s in String[]]) == Union{Nothing, Float64} |
311 | 318 | @test eltype([tryparse(Complex{Int}, s) for s in String[]]) == Union{Nothing, Complex{Int}} |
312 | 319 | 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 |
743 | 743 | end |
744 | 744 | end |
745 | 745 | |
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 | |
746 | 768 | |
747 | 769 | end # !withenv |
1405 | 1405 | @test @inferred(z4 .+ z4) === z4 |
1406 | 1406 | end |
1407 | 1407 | |
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 | ||
1408 | 1422 | @testset "allocation of TwicePrecision call" begin |
1409 | 1423 | 0:286.493442:360 |
1410 | 1424 | 0:286:360 |
159 | 159 | r = reinterpret(Int, vt) |
160 | 160 | @test r == OffsetArray(reshape(1:8, 2, 2, 2), (0, offsetvt...)) |
161 | 161 | 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) |
612 | 612 | end |
613 | 613 | end |
614 | 614 | |
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 | ||
615 | 636 | struct OpenInterval{T} |
616 | 637 | lower::T |
617 | 638 | upper::T |