diff --git a/base/array.jl b/base/array.jl index baef032f96b3f..be9eda37a2396 100644 --- a/base/array.jl +++ b/base/array.jl @@ -2308,7 +2308,7 @@ findall(testf::Function, A) = collect(first(p) for p in pairs(A) if testf(last(p # Broadcasting is much faster for small testf, and computing # integer indices from logical index using findall has a negligible cost -findall(testf::Function, A::AbstractArray) = findall(testf.(A)) +findall(testf::F, A::AbstractArray) where {F<:Function} = findall(testf.(A)) """ findall(A) diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 98bcfa4f18661..fae3def38c34d 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -111,7 +111,7 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f), result = abstract_call_method(interp, method, sig_n, svec(), multiple_matches, sv) rt = result.rt edge = result.edge - edge !== nothing && push!(edges, edge) + edge === nothing || push!(edges, edge) this_argtypes = isa(matches, MethodMatches) ? argtypes : matches.applicable_argtypes[i] this_arginfo = ArgInfo(fargs, this_argtypes) const_call_result = abstract_call_method_with_const_args(interp, result, @@ -136,25 +136,11 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f), this_conditional = ignorelimited(this_rt) this_rt = widenwrappedconditional(this_rt) else - if infer_compilation_signature(interp) - # Also infer the compilation signature for this method, so it's available - # to the compiler in case it ends up needing it (which is likely). - csig = get_compileable_sig(method, sig, match.sparams) - if csig !== nothing && csig !== sig - # The result of this inference is not directly used, so temporarily empty - # the use set for the current SSA value. - saved_uses = sv.ssavalue_uses[sv.currpc] - sv.ssavalue_uses[sv.currpc] = empty_bitset - abstract_call_method(interp, method, csig, match.sparams, multiple_matches, sv) - sv.ssavalue_uses[sv.currpc] = saved_uses - end - end - result = abstract_call_method(interp, method, sig, match.sparams, multiple_matches, sv) this_conditional = ignorelimited(result.rt) this_rt = widenwrappedconditional(result.rt) edge = result.edge - edge !== nothing && push!(edges, edge) + edge === nothing || push!(edges, edge) # try constant propagation with argtypes for this match # this is in preparation for inlining, or improving the return result this_argtypes = isa(matches, MethodMatches) ? argtypes : matches.applicable_argtypes[i] @@ -214,6 +200,26 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f), rettype = from_interprocedural!(rettype, sv, arginfo, conditionals) + # Also considering inferring the compilation signature for this method, so + # it is available to the compiler in case it ends up needing it. + if infer_compilation_signature(interp) && 1 == seen == napplicable && rettype !== Any && rettype !== Union{} && !is_removable_if_unused(all_effects) + match = applicable[1]::MethodMatch + method = match.method + sig = match.spec_types + mi = specialize_method(match; preexisting=true) + if mi !== nothing && !const_prop_methodinstance_heuristic(interp, match, mi::MethodInstance, arginfo, sv) + csig = get_compileable_sig(method, sig, match.sparams) + if csig !== nothing && csig !== sig + # The result of this inference is not directly used, so temporarily empty + # the use set for the current SSA value. + saved_uses = sv.ssavalue_uses[sv.currpc] + sv.ssavalue_uses[sv.currpc] = empty_bitset + abstract_call_method(interp, method, csig, match.sparams, multiple_matches, sv) + sv.ssavalue_uses[sv.currpc] = saved_uses + end + end + end + if call_result_unused(sv) && !(rettype === Bottom) add_remark!(interp, sv, "Call result type was widened because the return value is unused") # We're mainly only here because the optimizer might want this code, @@ -765,13 +771,25 @@ function collect_const_args((; argtypes)::ArgInfo) isa(a, Const) ? a.val : isconstType(a) ? (a::DataType).parameters[1] : (a::DataType).instance - end for i in 2:length(argtypes) ] + end for i = 2:length(argtypes) ] +end + +struct InvokeCall + types # ::Type + lookupsig # ::Type + InvokeCall(@nospecialize(types), @nospecialize(lookupsig)) = new(types, lookupsig) end function concrete_eval_call(interp::AbstractInterpreter, - @nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState) + @nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState, + invokecall::Union{Nothing,InvokeCall}=nothing) concrete_eval_eligible(interp, f, result, arginfo, sv) || return nothing args = collect_const_args(arginfo) + if invokecall !== nothing + # this call should be `invoke`d, rewrite `args` back now + pushfirst!(args, f, invokecall.types) + f = invoke + end world = get_world_counter(interp) value = try Core._call_in_world_total(world, f, args...) @@ -811,13 +829,13 @@ struct ConstCallResults new(rt, const_result, effects) end -function abstract_call_method_with_const_args(interp::AbstractInterpreter, result::MethodCallResult, - @nospecialize(f), arginfo::ArgInfo, match::MethodMatch, - sv::InferenceState) +function abstract_call_method_with_const_args(interp::AbstractInterpreter, + result::MethodCallResult, @nospecialize(f), arginfo::ArgInfo, match::MethodMatch, + sv::InferenceState, invokecall::Union{Nothing,InvokeCall}=nothing) if !const_prop_enabled(interp, sv, match) return nothing end - val = concrete_eval_call(interp, f, result, arginfo, sv) + val = concrete_eval_call(interp, f, result, arginfo, sv, invokecall) if val !== nothing add_backedge!(result.edge, sv) return val @@ -1547,10 +1565,10 @@ function abstract_invoke(interp::AbstractInterpreter, (; fargs, argtypes)::ArgIn nargtype isa DataType || return CallMeta(Any, Effects(), false) # other cases are not implemented below isdispatchelem(ft) || return CallMeta(Any, Effects(), false) # check that we might not have a subtype of `ft` at runtime, before doing supertype lookup below ft = ft::DataType - types = rewrap_unionall(Tuple{ft, unwrap_unionall(types).parameters...}, types)::Type + lookupsig = rewrap_unionall(Tuple{ft, unwrap_unionall(types).parameters...}, types)::Type nargtype = Tuple{ft, nargtype.parameters...} argtype = Tuple{ft, argtype.parameters...} - match, valid_worlds, overlayed = findsup(types, method_table(interp)) + match, valid_worlds, overlayed = findsup(lookupsig, method_table(interp)) match === nothing && return CallMeta(Any, Effects(), false) update_valid_age!(sv, valid_worlds) method = match.method @@ -1569,8 +1587,10 @@ function abstract_invoke(interp::AbstractInterpreter, (; fargs, argtypes)::ArgIn # t, a = ti.parameters[i], argtypes′[i] # argtypes′[i] = t ⊑ a ? t : a # end - const_call_result = abstract_call_method_with_const_args(interp, result, - overlayed ? nothing : singleton_type(ft′), arginfo, match, sv) + f = overlayed ? nothing : singleton_type(ft′) + invokecall = InvokeCall(types, lookupsig) + const_call_result = abstract_call_method_with_const_args(interp, + result, f, arginfo, match, sv, invokecall) const_result = nothing if const_call_result !== nothing if const_call_result.rt ⊑ rt diff --git a/base/compiler/ssair/inlining.jl b/base/compiler/ssair/inlining.jl index e51581e62569d..70e7038bbb8cc 100644 --- a/base/compiler/ssair/inlining.jl +++ b/base/compiler/ssair/inlining.jl @@ -1066,6 +1066,11 @@ function inline_invoke!( return nothing end +function invoke_signature(invokesig::Vector{Any}) + ft, argtyps = widenconst(invokesig[2]), instanceof_tfunc(widenconst(invokesig[3]))[1] + return rewrap_unionall(Tuple{ft, unwrap_unionall(argtyps).parameters...}, argtyps) +end + function narrow_opaque_closure!(ir::IRCode, stmt::Expr, @nospecialize(info), state::InliningState) if isa(info, OpaqueClosureCreateInfo) lbt = argextype(stmt.args[2], ir) diff --git a/base/gmp.jl b/base/gmp.jl index 435a0a0954ce9..59ab162429e87 100644 --- a/base/gmp.jl +++ b/base/gmp.jl @@ -667,8 +667,12 @@ function prod(arr::AbstractArray{BigInt}) # to account for the rounding to limbs in MPZ.mul! # (BITS_PER_LIMB-1 would typically be enough, to which we add # 1 for the initial multiplication by init=1 in foldl) - nbits = GC.@preserve arr sum(arr; init=BITS_PER_LIMB) do x - abs(x.size) * BITS_PER_LIMB - leading_zeros(unsafe_load(x.d)) + nbits = BITS_PER_LIMB + for x in arr + iszero(x) && return zero(BigInt) + xsize = abs(x.size) + lz = GC.@preserve x leading_zeros(unsafe_load(x.d, xsize)) + nbits += xsize * BITS_PER_LIMB - lz end init = BigInt(; nbits) MPZ.set_si!(init, 1) diff --git a/base/namedtuple.jl b/base/namedtuple.jl index 050d460f24724..5732dcd061b74 100644 --- a/base/namedtuple.jl +++ b/base/namedtuple.jl @@ -111,7 +111,8 @@ function NamedTuple{names}(nt::NamedTuple) where {names} types = Tuple{(fieldtype(nt, idx[n]) for n in 1:length(idx))...} Expr(:new, :(NamedTuple{names, $types}), Any[ :(getfield(nt, $(idx[n]))) for n in 1:length(idx) ]...) else - types = Tuple{(fieldtype(typeof(nt), names[n]) for n in 1:length(names))...} + length_names = length(names)::Integer + types = Tuple{(fieldtype(typeof(nt), names[n]) for n in 1:length_names)...} NamedTuple{names, types}(map(Fix1(getfield, nt), names)) end end diff --git a/base/ordering.jl b/base/ordering.jl index e49102159c962..d0c9cb99f9c72 100644 --- a/base/ordering.jl +++ b/base/ordering.jl @@ -122,7 +122,7 @@ lt(o::Lt, a, b) = o.lt(a,b) @propagate_inbounds function lt(p::Perm, a::Integer, b::Integer) da = p.data[a] db = p.data[b] - lt(p.order, da, db) | (!lt(p.order, db, da) & (a < b)) + (lt(p.order, da, db)::Bool) | (!(lt(p.order, db, da)::Bool) & (a < b)) end _ord(lt::typeof(isless), by::typeof(identity), order::Ordering) = order diff --git a/base/sort.jl b/base/sort.jl index b9c22e396db2c..b538428a8c424 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -496,7 +496,8 @@ const SMALL_ALGORITHM = InsertionSort const SMALL_THRESHOLD = 20 function sort!(v::AbstractVector, lo::Integer, hi::Integer, ::InsertionSortAlg, o::Ordering) - @inbounds for i = lo+1:hi + lo_plus_1 = (lo + 1)::Integer + @inbounds for i = lo_plus_1:hi j = i x = v[i] while j > lo diff --git a/base/special/exp.jl b/base/special/exp.jl index e955d182f29d3..cc4c8eee3323d 100644 --- a/base/special/exp.jl +++ b/base/special/exp.jl @@ -177,7 +177,7 @@ const J_TABLE = (0x0000000000000000, 0xaac00b1afa5abcbe, 0x9b60163da9fb3335, 0xa # XXX we want to mark :consistent-cy here so that this function can be concrete-folded, # because the effect analysis currently can't prove it in the presence of `@inbounds` or # `:boundscheck`, but still the access to `J_TABLE` is really safe here -@noinline Base.@assume_effects :consistent @inline function table_unpack(ind::Int32) +Base.@assume_effects :consistent function table_unpack(ind::Int32) ind = ind & 255 + 1 # 255 == length(J_TABLE) - 1 j = @inbounds J_TABLE[ind] jU = reinterpret(Float64, JU_CONST | (j&JU_MASK)) diff --git a/deps/checksums/Tar-0f8a73d5cd4b0c8f1f3c36799c96e9515e9dc595.tar.gz/md5 b/deps/checksums/Tar-0f8a73d5cd4b0c8f1f3c36799c96e9515e9dc595.tar.gz/md5 deleted file mode 100644 index 60ff3e45e5336..0000000000000 --- a/deps/checksums/Tar-0f8a73d5cd4b0c8f1f3c36799c96e9515e9dc595.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -faf67b4fe8308fc6f9d7ed9bfbd855a9 diff --git a/deps/checksums/Tar-0f8a73d5cd4b0c8f1f3c36799c96e9515e9dc595.tar.gz/sha512 b/deps/checksums/Tar-0f8a73d5cd4b0c8f1f3c36799c96e9515e9dc595.tar.gz/sha512 deleted file mode 100644 index b2e786c204e70..0000000000000 --- a/deps/checksums/Tar-0f8a73d5cd4b0c8f1f3c36799c96e9515e9dc595.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -d97bd68d6d651ec13f399f9124cc0abba7092532b467fdcbb9c886f5f3d121e79392bfce7c6e631178ff175131360415a98645661da0f9c83f27db50691ce133 diff --git a/deps/checksums/Tar-c9e71856688bffacda56e1e2926a741bbb6e4784.tar.gz/md5 b/deps/checksums/Tar-c9e71856688bffacda56e1e2926a741bbb6e4784.tar.gz/md5 new file mode 100644 index 0000000000000..bddd86b3a714c --- /dev/null +++ b/deps/checksums/Tar-c9e71856688bffacda56e1e2926a741bbb6e4784.tar.gz/md5 @@ -0,0 +1 @@ +47f02b8f77000fc3aa53c48fadc07f58 diff --git a/deps/checksums/Tar-c9e71856688bffacda56e1e2926a741bbb6e4784.tar.gz/sha512 b/deps/checksums/Tar-c9e71856688bffacda56e1e2926a741bbb6e4784.tar.gz/sha512 new file mode 100644 index 0000000000000..bc3e07d23b5a9 --- /dev/null +++ b/deps/checksums/Tar-c9e71856688bffacda56e1e2926a741bbb6e4784.tar.gz/sha512 @@ -0,0 +1 @@ +0aa074c752083c7c1357060c34e161356fcbe9bc27a2dd9bf1c5f0f51fe7bf2ea1b6dc2227c873a2605fa28332e98ff1fb1077f7870dc3e944590e47e38b7f6b diff --git a/stdlib/Artifacts/src/Artifacts.jl b/stdlib/Artifacts/src/Artifacts.jl index 724bda22ae531..25d8b254c7cfc 100644 --- a/stdlib/Artifacts/src/Artifacts.jl +++ b/stdlib/Artifacts/src/Artifacts.jl @@ -325,7 +325,7 @@ function process_overrides(artifact_dict::Dict, pkg_uuid::Base.UUID) # override for this UUID, and inserting new overrides for those hashes. overrides = load_overrides() if haskey(overrides[:UUID], pkg_uuid) - pkg_overrides = overrides[:UUID][pkg_uuid] + pkg_overrides = overrides[:UUID][pkg_uuid]::Dict{String, <:Any} for name in keys(artifact_dict) # Skip names that we're not overriding diff --git a/stdlib/InteractiveUtils/src/macros.jl b/stdlib/InteractiveUtils/src/macros.jl index 7c4ce6f0dd588..d9dcff57257c9 100644 --- a/stdlib/InteractiveUtils/src/macros.jl +++ b/stdlib/InteractiveUtils/src/macros.jl @@ -24,7 +24,8 @@ function recursive_dotcalls!(ex, args, i=1) end end (start, branches) = ex.head === :. ? (1, ex.args[2].args) : (2, ex.args) - for j in start:length(branches) + length_branches = length(branches)::Integer + for j in start:length_branches branch, i = recursive_dotcalls!(branches[j], args, i) branches[j] = branch end diff --git a/stdlib/LibGit2/src/consts.jl b/stdlib/LibGit2/src/consts.jl index 2bc9edaf8950b..55887ebe2a8ab 100644 --- a/stdlib/LibGit2/src/consts.jl +++ b/stdlib/LibGit2/src/consts.jl @@ -247,6 +247,11 @@ const RESET_HARD = Cint(3) # MIXED plus changes in working tree discarded REBASE_OPERATION_FIXUP = Cint(4), REBASE_OPERATION_EXEC = Cint(5)) +# git_remote_redirect_t +const GIT_REMOTE_REDIRECT_NONE = Cint(0) +const GIT_REMOTE_REDIRECT_INITIAL = Cint(1) +const GIT_REMOTE_REDIRECT_ALL = Cint(2) + # fetch_prune const FETCH_PRUNE_UNSPECIFIED = Cint(0) const FETCH_PRUNE = Cint(1) diff --git a/stdlib/LibGit2/src/types.jl b/stdlib/LibGit2/src/types.jl index 2d95596cb276d..211bb4c08ad26 100644 --- a/stdlib/LibGit2/src/types.jl +++ b/stdlib/LibGit2/src/types.jl @@ -346,6 +346,9 @@ The fields represent: @static if LibGit2.VERSION >= v"0.25.0" proxy_opts::ProxyOptions = ProxyOptions() end + @static if LibGit2.VERSION >= v"1.4.0" + follow_redirects::Cint = Consts.GIT_REMOTE_REDIRECT_INITIAL + end @static if LibGit2.VERSION >= v"0.24.0" custom_headers::StrArrayStruct = StrArrayStruct() end @@ -677,6 +680,9 @@ The fields represent: @static if LibGit2.VERSION >= v"0.25.0" proxy_opts::ProxyOptions = ProxyOptions() end + @static if LibGit2.VERSION >= v"1.4.0" + follow_redirects::Cint = Consts.GIT_REMOTE_REDIRECT_INITIAL + end @static if LibGit2.VERSION >= v"0.24.0" custom_headers::StrArrayStruct = StrArrayStruct() end diff --git a/stdlib/Printf/src/Printf.jl b/stdlib/Printf/src/Printf.jl index 05e1621dcb795..78381cef59cb2 100644 --- a/stdlib/Printf/src/Printf.jl +++ b/stdlib/Printf/src/Printf.jl @@ -242,7 +242,7 @@ end @inline function fmt(buf, pos, arg, spec::Spec{T}) where {T <: Strings} leftalign, hash, width, prec = spec.leftalign, spec.hash, spec.width, spec.precision str = string(arg) - slen = textwidth(str) + (hash ? arg isa AbstractString ? 2 : 1 : 0) + slen = textwidth(str)::Int + (hash ? arg isa AbstractString ? 2 : 1 : 0) op = p = prec == -1 ? slen : min(slen, prec) if !leftalign && width > p for _ = 1:(width - p) diff --git a/stdlib/Tar.version b/stdlib/Tar.version index b7ee00e5a2666..6039b8428736e 100644 --- a/stdlib/Tar.version +++ b/stdlib/Tar.version @@ -1,4 +1,4 @@ -TAR_BRANCH = master -TAR_SHA1 = 0f8a73d5cd4b0c8f1f3c36799c96e9515e9dc595 +TAR_BRANCH = release-1.10 +TAR_SHA1 = c9e71856688bffacda56e1e2926a741bbb6e4784 TAR_GIT_URL := https://github.com/JuliaIO/Tar.jl.git TAR_TAR_URL = https://api.github.com/repos/JuliaIO/Tar.jl/tarball/$1 diff --git a/test/compiler/inference.jl b/test/compiler/inference.jl index 70a720e53f209..00470aaccf248 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -4074,3 +4074,24 @@ end)[2] == Union{} @time 1 end end)[2] == Union{} + +invoke_concretized1(a::Int) = a > 0 ? :int : nothing +invoke_concretized1(a::Integer) = a > 0 ? "integer" : nothing +# check if `invoke(invoke_concretized1, Tuple{Integer}, ::Int)` is foldable +@test Base.infer_effects((Int,)) do a + Base.@invoke invoke_concretized1(a::Integer) +end |> Core.Compiler.is_foldable +@test Base.return_types() do + Base.@invoke invoke_concretized1(42::Integer) +end |> only === String + +invoke_concretized2(a::Int) = a > 0 ? :int : nothing +invoke_concretized2(a::Integer) = a > 0 ? :integer : nothing +# check if `invoke(invoke_concretized2, Tuple{Integer}, ::Int)` is foldable +@test Base.infer_effects((Int,)) do a + Base.@invoke invoke_concretized2(a::Integer) +end |> Core.Compiler.is_foldable +@test let + Base.Experimental.@force_compile + Base.@invoke invoke_concretized2(42::Integer) +end === :integer diff --git a/test/gmp.jl b/test/gmp.jl index 2eb1e9faf47da..1d30925071b9a 100644 --- a/test/gmp.jl +++ b/test/gmp.jl @@ -227,6 +227,7 @@ let a, b @test 0 == sum(BigInt[]) isa BigInt @test prod(b) == foldl(*, b) @test 1 == prod(BigInt[]) isa BigInt + @test prod(BigInt[0, 0, 0]) == 0 # issue #46665 end @testset "Iterated arithmetic" begin