Skip to content

Commit d97505c

Browse files
authored
Merge branch 'master' into rationalize_irrational
2 parents 9fb836d + da74ef1 commit d97505c

133 files changed

Lines changed: 2817 additions & 1371 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

HISTORY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ Standard library changes
136136
`AnnotatedString` with various faces or other attributes applied ([#49586]).
137137

138138
#### Package Manager
139+
* It is now possible to specify "sources" for packages in a `[sources]` section in Project.toml.
140+
This can be used to add non-registered normal or test dependencies.
141+
* Pkg now obeys `[compat]` bounds for `julia` and raises an error if the version of the running Julia binary is incompatible with the bounds in `Project.toml`.
142+
Pkg has always obeyed this compat when working with Registry packages. This change affects mostly local packages
143+
* `pkg> add` and `Pkg.add` will now add compat entries for new direct dependencies if the active environment is a
144+
package (has a `name` and `uuid` entry).
145+
* Dependencies can now be directly added as weak deps or extras via the `pkg> add --weak/extra Foo` or
146+
`Pkg.add("Foo", target=:weakdeps/:extras)` forms.
139147

140148
#### LinearAlgebra
141149
* `cbrt(::AbstractMatrix{<:Real})` is now defined and returns real-valued matrix cube roots of real-valued matrices ([#50661]).

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ New library features
116116
the uniquing checking ([#53474])
117117
* `RegexMatch` objects can now be used to construct `NamedTuple`s and `Dict`s ([#50988])
118118
* `Lockable` is now exported ([#54595])
119+
* `Base.require_one_based_indexing` and `Base.has_offset_axes` are now public ([#56196])
119120
* New `ltruncate`, `rtruncate` and `ctruncate` functions for truncating strings to text width, accounting for char widths ([#55351])
121+
* `isless` (and thus `cmp`, sorting, etc.) is now supported for zero-dimensional `AbstractArray`s ([#55772])
120122

121123
Standard library changes
122124
------------------------
@@ -148,6 +150,8 @@ Standard library changes
148150
Custom array types may specialize this function to return an appropriate result ([#55252]).
149151
* The matrix multiplication `A * B` calls `matprod_dest(A, B, T::Type)` to generate the destination.
150152
This function is now public ([#55537]).
153+
* The function `haszero(T::Type)` is used to check if a type `T` has a unique zero element defined as `zero(T)`.
154+
This is now public.
151155

152156
#### Logging
153157

@@ -211,4 +215,6 @@ External dependencies
211215
Tooling Improvements
212216
--------------------
213217

218+
- A wall-time profiler is now available for users who need a sampling profiler that captures tasks regardless of their scheduling or running state. This type of profiler enables profiling of I/O-heavy tasks and helps detect areas of heavy contention in the system ([#55889]).
219+
214220
<!--- generated by NEWS-update.jl: -->

base/Base.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ function include(mod::Module, path::String)
2525
end
2626
include(path::String) = include(Base, path)
2727

28+
struct IncludeInto <: Function
29+
m::Module
30+
end
31+
(this::IncludeInto)(fname::AbstractString) = include(this.m, fname)
32+
2833
# from now on, this is now a top-module for resolving syntax
2934
const is_primary_base_module = ccall(:jl_module_parent, Ref{Module}, (Any,), Base) === Core.Main
3035
ccall(:jl_set_istopmod, Cvoid, (Any, Bool), Base, is_primary_base_module)
@@ -572,15 +577,20 @@ include("precompilation.jl")
572577
for m in methods(include)
573578
delete_method(m)
574579
end
580+
for m in methods(IncludeInto(Base))
581+
delete_method(m)
582+
end
575583

576584
# This method is here only to be overwritten during the test suite to test
577585
# various sysimg related invalidation scenarios.
578586
a_method_to_overwrite_in_test() = inferencebarrier(1)
579587

580588
# These functions are duplicated in client.jl/include(::String) for
581589
# nicer stacktraces. Modifications here have to be backported there
582-
include(mod::Module, _path::AbstractString) = _include(identity, mod, _path)
583-
include(mapexpr::Function, mod::Module, _path::AbstractString) = _include(mapexpr, mod, _path)
590+
@noinline include(mod::Module, _path::AbstractString) = _include(identity, mod, _path)
591+
@noinline include(mapexpr::Function, mod::Module, _path::AbstractString) = _include(mapexpr, mod, _path)
592+
(this::IncludeInto)(fname::AbstractString) = include(identity, this.m, fname)
593+
(this::IncludeInto)(mapexpr::Function, fname::AbstractString) = include(mapexpr, this.m, fname)
584594

585595
# External libraries vendored into Base
586596
Core.println("JuliaSyntax/src/JuliaSyntax.jl")
@@ -646,10 +656,9 @@ function __init__()
646656
init_load_path()
647657
init_active_project()
648658
append!(empty!(_sysimage_modules), keys(loaded_modules))
649-
empty!(explicit_loaded_modules)
650659
empty!(loaded_precompiles) # If we load a packageimage when building the image this might not be empty
651-
for (mod, key) in module_keys
652-
push!(get!(Vector{Module}, loaded_precompiles, key), mod)
660+
for mod in loaded_modules_order
661+
push!(get!(Vector{Module}, loaded_precompiles, PkgId(mod)), mod)
653662
end
654663
if haskey(ENV, "JULIA_MAX_NUM_PRECOMPILE_FILES")
655664
MAX_NUM_PRECOMPILE_FILES[] = parse(Int, ENV["JULIA_MAX_NUM_PRECOMPILE_FILES"])

base/abstractarray.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,6 +3044,15 @@ function cmp(A::AbstractVector, B::AbstractVector)
30443044
return cmp(length(A), length(B))
30453045
end
30463046

3047+
"""
3048+
isless(A::AbstractArray{<:Any,0}, B::AbstractArray{<:Any,0})
3049+
3050+
Return `true` when the only element of `A` is less than the only element of `B`.
3051+
"""
3052+
function isless(A::AbstractArray{<:Any,0}, B::AbstractArray{<:Any,0})
3053+
isless(only(A), only(B))
3054+
end
3055+
30473056
"""
30483057
isless(A::AbstractVector, B::AbstractVector)
30493058

base/boot.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,13 @@ Nothing() = nothing
454454
# This should always be inlined
455455
getptls() = ccall(:jl_get_ptls_states, Ptr{Cvoid}, ())
456456

457-
include(m::Module, fname::String) = ccall(:jl_load_, Any, (Any, Any), m, fname)
457+
include(m::Module, fname::String) = (@noinline; ccall(:jl_load_, Any, (Any, Any), m, fname))
458+
eval(m::Module, @nospecialize(e)) = (@noinline; ccall(:jl_toplevel_eval_in, Any, (Any, Any), m, e))
458459

459-
eval(m::Module, @nospecialize(e)) = ccall(:jl_toplevel_eval_in, Any, (Any, Any), m, e)
460+
struct EvalInto <: Function
461+
m::Module
462+
end
463+
(this::EvalInto)(@nospecialize(e)) = eval(this.m, e)
460464

461465
mutable struct Box
462466
contents::Any

base/compiler/abstractinterpretation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3648,7 +3648,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState, nextr
36483648
changes = StateUpdate(lhs, VarState(rt, false))
36493649
elseif isa(lhs, GlobalRef)
36503650
handle_global_assignment!(interp, frame, lhs, rt)
3651-
elseif !isa(lhs, SSAValue)
3651+
else
36523652
merge_effects!(interp, frame, EFFECTS_UNKNOWN)
36533653
end
36543654
end

base/compiler/ssair/inlining.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ function analyze_method!(match::MethodMatch, argtypes::Vector{Any},
939939
allow_typevars::Bool, invokesig::Union{Nothing,Vector{Any}}=nothing,
940940
volatile_inf_result::Union{Nothing,VolatileInferenceResult}=nothing)
941941
method = match.method
942-
spec_types = match.spec_types
943942

944943
# Check that we have the correct number of arguments
945944
na = Int(method.nargs)
@@ -954,6 +953,7 @@ function analyze_method!(match::MethodMatch, argtypes::Vector{Any},
954953
if !match.fully_covers
955954
# type-intersection was not able to give us a simple list of types, so
956955
# ir_inline_unionsplit won't be able to deal with inlining this
956+
spec_types = match.spec_types
957957
if !(spec_types isa DataType && length(spec_types.parameters) == npassedargs &&
958958
!isvarargtype(spec_types.parameters[end]))
959959
return nothing
@@ -1428,28 +1428,26 @@ function handle_match!(cases::Vector{InliningCase},
14281428
match::MethodMatch, argtypes::Vector{Any}, @nospecialize(info::CallInfo), flag::UInt32,
14291429
state::InliningState;
14301430
allow_typevars::Bool, volatile_inf_result::Union{Nothing,VolatileInferenceResult})
1431-
spec_types = match.spec_types
14321431
# We may see duplicated dispatch signatures here when a signature gets widened
14331432
# during abstract interpretation: for the purpose of inlining, we can just skip
14341433
# processing this dispatch candidate (unless unmatched type parameters are present)
1435-
!allow_typevars && any(case::InliningCase->case.sig === spec_types, cases) && return true
1434+
!allow_typevars && any(case::InliningCase->case.sig === match.spec_types, cases) && return true
14361435
item = analyze_method!(match, argtypes, info, flag, state; allow_typevars, volatile_inf_result)
14371436
item === nothing && return false
1438-
push!(cases, InliningCase(spec_types, item))
1437+
push!(cases, InliningCase(match.spec_types, item))
14391438
return true
14401439
end
14411440

14421441
function handle_const_prop_result!(cases::Vector{InliningCase}, result::ConstPropResult,
14431442
match::MethodMatch, @nospecialize(info::CallInfo), flag::UInt32, state::InliningState;
14441443
allow_typevars::Bool)
14451444
mi = result.result.linfo
1446-
spec_types = match.spec_types
14471445
if !validate_sparams(mi.sparam_vals)
14481446
(allow_typevars && !may_have_fcalls(mi.def::Method)) || return false
14491447
end
14501448
item = resolve_todo(mi, result.result, info, flag, state)
14511449
item === nothing && return false
1452-
push!(cases, InliningCase(spec_types, item))
1450+
push!(cases, InliningCase(match.spec_types, item))
14531451
return true
14541452
end
14551453

@@ -1479,11 +1477,10 @@ end
14791477
function handle_semi_concrete_result!(cases::Vector{InliningCase}, result::SemiConcreteResult,
14801478
match::MethodMatch, @nospecialize(info::CallInfo), flag::UInt32, state::InliningState)
14811479
mi = result.mi
1482-
spec_types = match.spec_types
14831480
validate_sparams(mi.sparam_vals) || return false
14841481
item = semiconcrete_result_item(result, info, flag, state)
14851482
item === nothing && return false
1486-
push!(cases, InliningCase(spec_types, item))
1483+
push!(cases, InliningCase(match.spec_types, item))
14871484
return true
14881485
end
14891486

base/compiler/tfuncs.jl

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,16 @@ add_tfunc(svec, 0, INT_INF, @nospecs((𝕃::AbstractLattice, args...)->SimpleVec
601601
return TypeVar
602602
end
603603
end
604-
tv = TypeVar(nval, lb, ub)
605-
return PartialTypeVar(tv, lb_certain, ub_certain)
604+
lb_valid = lb isa Type || lb isa TypeVar
605+
ub_valid = ub isa Type || ub isa TypeVar
606+
if lb_valid && ub_valid
607+
tv = TypeVar(nval, lb, ub)
608+
return PartialTypeVar(tv, lb_certain, ub_certain)
609+
elseif !lb_valid && lb_certain
610+
return Union{}
611+
elseif !ub_valid && ub_certain
612+
return Union{}
613+
end
606614
end
607615
return TypeVar
608616
end
@@ -1339,13 +1347,15 @@ end
13391347
return getfield_tfunc(𝕃, o, f)
13401348
end
13411349
@nospecs function modifyfield!_tfunc(𝕃::AbstractLattice, o, f, op, v, order=Symbol)
1342-
T = _fieldtype_tfunc(𝕃, o, f, isconcretetype(o))
1350+
o′ = widenconst(o)
1351+
T = _fieldtype_tfunc(𝕃, o′, f, isconcretetype(o′))
13431352
T === Bottom && return Bottom
13441353
PT = Const(Pair)
13451354
return instanceof_tfunc(apply_type_tfunc(𝕃, PT, T, T), true)[1]
13461355
end
13471356
@nospecs function replacefield!_tfunc(𝕃::AbstractLattice, o, f, x, v, success_order=Symbol, failure_order=Symbol)
1348-
T = _fieldtype_tfunc(𝕃, o, f, isconcretetype(o))
1357+
o′ = widenconst(o)
1358+
T = _fieldtype_tfunc(𝕃, o′, f, isconcretetype(o′))
13491359
T === Bottom && return Bottom
13501360
PT = Const(ccall(:jl_apply_cmpswap_type, Any, (Any,), T) where T)
13511361
return instanceof_tfunc(apply_type_tfunc(𝕃, PT, T), true)[1]
@@ -2998,14 +3008,16 @@ function abstract_applicable(interp::AbstractInterpreter, argtypes::Vector{Any},
29983008
else
29993009
rt = Const(true) # has applicable matches
30003010
end
3001-
for i in 1:napplicable
3002-
match = applicable[i]::MethodMatch
3003-
edge = specialize_method(match)::MethodInstance
3004-
add_backedge!(sv, edge)
3011+
if rt !== Bool
3012+
for i in 1:napplicable
3013+
match = applicable[i]::MethodMatch
3014+
edge = specialize_method(match)
3015+
add_backedge!(sv, edge)
3016+
end
3017+
# also need an edge to the method table in case something gets
3018+
# added that did not intersect with any existing method
3019+
add_uncovered_edges!(sv, matches, atype)
30053020
end
3006-
# also need an edge to the method table in case something gets
3007-
# added that did not intersect with any existing method
3008-
add_uncovered_edges!(sv, matches, atype)
30093021
end
30103022
return Future(CallMeta(rt, Union{}, EFFECTS_TOTAL, NoCallInfo()))
30113023
end

base/coreio.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
print(x) = print(stdout, x)
4+
print(x1, x2) = print(stdout, x1, x2)
5+
println(x) = print(stdout, x, "\n")
6+
println(x1, x2) = print(stdout, x1, x2, "\n")
7+
38
print(xs...) = print(stdout, xs...)
4-
println(xs...) = println(stdout, xs...)
5-
println(io::IO) = print(io, '\n')
9+
println(xs...) = print(stdout, xs..., "\n") # fewer allocations than `println(stdout, xs...)`
10+
println(io::IO) = print(io, "\n")
611

712
function show end
813
function repr end

base/docs/basedocs.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ kw"help", kw"Julia", kw"julia", kw""
3737
available for direct use. Names can also be used via dot syntax (e.g. `Foo.foo` to access
3838
the name `foo`), whether they are `export`ed or not.
3939
See the [manual section about modules](@ref modules) for details.
40+
41+
!!! note
42+
When two or more packages/modules export a name and that name does not refer to the
43+
same thing in each of the packages, and the packages are loaded via `using` without
44+
an explicit list of names, it is an error to reference that name without qualification.
45+
It is thus recommended that code intended to be forward-compatible with future versions
46+
of its dependencies and of Julia, e.g., code in released packages, list the names it
47+
uses from each loaded package, e.g., `using Foo: Foo, f` rather than `using Foo`.
4048
"""
4149
kw"using"
4250

@@ -2580,7 +2588,7 @@ cases.
25802588
See also [`setproperty!`](@ref Base.setproperty!) and [`getglobal`](@ref)
25812589
25822590
# Examples
2583-
```jldoctest; filter = r"Stacktrace:(\\n \\[[0-9]+\\].*)*"
2591+
```jldoctest; filter = r"Stacktrace:(\\n \\[[0-9]+\\].*\\n.*)*"
25842592
julia> module M; global a; end;
25852593
25862594
julia> M.a # same as `getglobal(M, :a)`

0 commit comments

Comments
 (0)