Skip to content

Commit bf04a2a

Browse files
committed
Merge branch 'master' into structured_opnorm
2 parents 9142ad4 + e5e1253 commit bf04a2a

File tree

260 files changed

+1474
-558
lines changed

Some content is hidden

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

260 files changed

+1474
-558
lines changed

.travis.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,18 @@ before_install:
7373
export PATH="$(brew --prefix ccache)/libexec:$PATH";
7474
BAR="pv -i 30";
7575
contrib/travis_fastfail.sh || exit 1;
76-
brew tap staticfloat/julia > /dev/null;
77-
brew rm --force $(brew deps --HEAD julia);
78-
brew install -v ccache gcc gmp mpfr pcre2 staticfloat/julia/openblas-julia staticfloat/julia/suite-sparse-julia staticfloat/juliadeps/libgfortran;
79-
BUILDOPTS="-j3 USECLANG=1 USECCACHE=1 USE_BINARYBUILDER_LLVM=1 USE_BINARYBUILDER_OPENBLAS=1 BINARYBUILDER_LLVM_ASSERTS=1";
80-
BUILDOPTS="$BUILDOPTS LLVM_CONFIG=$TRAVIS_BUILD_DIR/usr/tools/llvm-config LLVM_SIZE=$TRAVIS_BUILD_DIR/usr/tools/llvm-size";
81-
BUILDOPTS="$BUILDOPTS VERBOSE=1 USE_BLAS64=0 SUITESPARSE_INC=-I$(brew --prefix suite-sparse-julia)/include FORCE_ASSERTIONS=1";
82-
BUILDOPTS="$BUILDOPTS LIBBLAS=-lopenblas LIBBLASNAME=libopenblas LIBLAPACK=-lopenblas LIBLAPACKNAME=libopenblas";
83-
for lib in SUITESPARSE BLAS LAPACK GMP MPFR LIBUNWIND; do
76+
brew rm --force gcc gmp mpfr pcre2;
77+
brew install -v gcc gmp mpfr pcre2;
78+
BUILDOPTS="-j3 USECLANG=1 USECCACHE=1 VERBOSE=1 FORCE_ASSERTIONS=1";
79+
for proj in LLVM LLVM_ASSERTS OPENBLAS SUITESPARSE OPENLIBM; do
80+
BUILDOPTS="$BUILDOPTS USE_BINARYBUILDER_${proj}=1";
81+
done;
82+
for lib in GMP MPFR LIBUNWIND; do
8483
BUILDOPTS="$BUILDOPTS USE_SYSTEM_$lib=1";
8584
done;
86-
export LDFLAGS="-L$(brew --prefix openblas-julia)/lib -L$(brew --prefix suite-sparse-julia)/lib";
8785
spawn_DYLD_FALLBACK_LIBRARY_PATH="/usr/local/lib:/lib:/usr/lib";
88-
spawn_DYLD_FALLBACK_LIBRARY_PATH+=":$(brew --prefix openblas-julia)/lib";
89-
spawn_DYLD_FALLBACK_LIBRARY_PATH+=":$(brew --prefix suite-sparse-julia)/lib";
9086
export JULIA_MACOS_SPAWN="DYLD_FALLBACK_LIBRARY_PATH=\"$spawn_DYLD_FALLBACK_LIBRARY_PATH\" \$1";
9187
export BUILDOPTS="$BUILDOPTS spawn=\$(JULIA_MACOS_SPAWN)";
92-
make $BUILDOPTS -C contrib -f repackage_system_suitesparse4.make;
9388
export JULIA_CPU_THREADS=2;
9489
export JULIA_TEST_MAXRSS_MB=600;
9590
TESTSTORUN="all --skip linalg/triangular subarray"; fi # TODO: re enable these if possible without timing out

NEWS.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Multi-threading changes
1515

1616
Language changes
1717
----------------
18-
18+
* Empty entries in `JULIA_DEPOT_PATH` are now expanded to default depot entries ([#31009]).
1919
* `Enum` now behaves like a scalar when used in broadcasting ([#30670]).
2020

2121
Command-line option changes
@@ -33,10 +33,12 @@ New library functions
3333
Standard library changes
3434
------------------------
3535

36-
* The `extrema` function now accepts a function argument in the same manner as `minimum` and
37-
`maximum` ([#30323]).
38-
* `hasmethod` can now check for matching keyword argument names ([#30712]).
39-
* `startswith` and `endswith` now accept a `Regex` for the second argument ([#29790]).
36+
* The `extrema` function now accepts a function argument in the same manner as `minimum` and
37+
`maximum` ([#30323]).
38+
* `hasmethod` can now check for matching keyword argument names ([#30712]).
39+
* `startswith` and `endswith` now accept a `Regex` for the second argument ([#29790]).
40+
* `retry` supports arbitrary callable objects ([#30382]).
41+
* A no-argument construct to `Ptr{T}` has been added which constructs a null pointer ([#30919])
4042

4143
#### LinearAlgebra
4244

@@ -78,6 +80,7 @@ Deprecated or removed
7880
[#21598]: https://github.com/JuliaLang/julia/issues/21598
7981
[#24980]: https://github.com/JuliaLang/julia/issues/24980
8082
[#28850]: https://github.com/JuliaLang/julia/issues/28850
83+
[#29777]: https://github.com/JuliaLang/julia/issues/29777
8184
[#29790]: https://github.com/JuliaLang/julia/issues/29790
8285
[#29998]: https://github.com/JuliaLang/julia/issues/29998
8386
[#30061]: https://github.com/JuliaLang/julia/issues/30061
@@ -86,6 +89,8 @@ Deprecated or removed
8689
[#30323]: https://github.com/JuliaLang/julia/issues/30323
8790
[#30349]: https://github.com/JuliaLang/julia/issues/30349
8891
[#30372]: https://github.com/JuliaLang/julia/issues/30372
92+
[#30382]: https://github.com/JuliaLang/julia/issues/30382
93+
[#30577]: https://github.com/JuliaLang/julia/issues/30577
8994
[#30583]: https://github.com/JuliaLang/julia/issues/30583
9095
[#30584]: https://github.com/JuliaLang/julia/issues/30584
9196
[#30593]: https://github.com/JuliaLang/julia/issues/30593
@@ -94,3 +99,4 @@ Deprecated or removed
9499
[#30712]: https://github.com/JuliaLang/julia/issues/30712
95100
[#30724]: https://github.com/JuliaLang/julia/issues/30724
96101
[#30915]: https://github.com/JuliaLang/julia/issues/30915
102+
[#30919]: https://github.com/JuliaLang/julia/issues/30919

base/Enums.jl

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Enums
55
import Core.Intrinsics.bitcast
66
export Enum, @enum
77

8-
function basetype end
8+
function namemap end
99

1010
"""
1111
Enum{T<:Integer}
@@ -14,10 +14,48 @@ The abstract supertype of all enumerated types defined with [`@enum`](@ref).
1414
"""
1515
abstract type Enum{T<:Integer} end
1616

17+
basetype(::Type{<:Enum{T}}) where {T<:Integer} = T
18+
1719
(::Type{T})(x::Enum{T2}) where {T<:Integer,T2<:Integer} = T(bitcast(T2, x))::T
1820
Base.cconvert(::Type{T}, x::Enum{T2}) where {T<:Integer,T2<:Integer} = T(x)
1921
Base.write(io::IO, x::Enum{T}) where {T<:Integer} = write(io, T(x))
20-
Base.read(io::IO, ::Type{T}) where {T<:Enum} = T(read(io, Enums.basetype(T)))
22+
Base.read(io::IO, ::Type{T}) where {T<:Enum} = T(read(io, basetype(T)))
23+
24+
Base.isless(x::T, y::T) where {T<:Enum} = isless(basetype(T)(x), basetype(T)(y))
25+
26+
Base.Symbol(x::Enum) = namemap(typeof(x))[Integer(x)]::Symbol
27+
28+
Base.print(io::IO, x::Enum) = print(io, Symbol(x))
29+
30+
function Base.show(io::IO, x::Enum)
31+
sym = Symbol(x)
32+
if !get(io, :compact, false)
33+
from = get(io, :module, Main)
34+
def = typeof(x).name.module
35+
if from === nothing || !Base.isvisible(sym, def, from)
36+
show(io, def)
37+
print(io, ".")
38+
end
39+
end
40+
print(io, sym)
41+
end
42+
43+
function Base.show(io::IO, ::MIME"text/plain", x::Enum)
44+
print(io, x, "::")
45+
show(IOContext(io, :compact => true), typeof(x))
46+
print(io, " = ")
47+
show(io, Integer(x))
48+
end
49+
50+
function Base.show(io::IO, ::MIME"text/plain", t::Type{<:Enum})
51+
print(io, "Enum ")
52+
Base.show_datatype(io, t)
53+
print(io, ":")
54+
for x in instances(t)
55+
print(io, "\n", Symbol(x), " = ")
56+
show(io, Integer(x))
57+
end
58+
end
2159

2260
# generate code to test whether expr is in the given set of values
2361
function membershiptest(expr, values)
@@ -74,7 +112,7 @@ To list all the instances of an enum use `instances`, e.g.
74112
75113
```jldoctest fruitenum
76114
julia> instances(Fruit)
77-
(apple::Fruit = 1, orange::Fruit = 2, kiwi::Fruit = 3)
115+
(apple, orange, kiwi)
78116
```
79117
"""
80118
macro enum(T, syms...)
@@ -92,7 +130,9 @@ macro enum(T, syms...)
92130
elseif !isa(T, Symbol)
93131
throw(ArgumentError("invalid type expression for enum $T"))
94132
end
95-
vals = Vector{Tuple{Symbol,Integer}}()
133+
values = basetype[]
134+
seen = Set{Symbol}()
135+
namemap = Dict{basetype,Symbol}()
96136
lo = hi = 0
97137
i = zero(basetype)
98138
hasexpr = false
@@ -103,7 +143,7 @@ macro enum(T, syms...)
103143
for s in syms
104144
s isa LineNumberNode && continue
105145
if isa(s, Symbol)
106-
if i == typemin(basetype) && !isempty(vals)
146+
if i == typemin(basetype) && !isempty(values)
107147
throw(ArgumentError("overflow in value \"$s\" of Enum $typename"))
108148
end
109149
elseif isa(s, Expr) &&
@@ -120,64 +160,41 @@ macro enum(T, syms...)
120160
throw(ArgumentError(string("invalid argument for Enum ", typename, ": ", s)))
121161
end
122162
if !Base.isidentifier(s)
123-
throw(ArgumentError("invalid name for Enum $typename; \"$s\" is not a valid identifier."))
163+
throw(ArgumentError("invalid name for Enum $typename; \"$s\" is not a valid identifier"))
164+
end
165+
if hasexpr && haskey(namemap, i)
166+
throw(ArgumentError("both $s and $(namemap[i]) have value $i in Enum $typename; values must be unique"))
124167
end
125-
push!(vals, (s,i))
126-
if length(vals) == 1
168+
namemap[i] = s
169+
push!(values, i)
170+
if s in seen
171+
throw(ArgumentError("name \"$s\" in Enum $typename is not unique"))
172+
end
173+
push!(seen, s)
174+
if length(values) == 1
127175
lo = hi = i
128176
else
129177
lo = min(lo, i)
130178
hi = max(hi, i)
131179
end
132180
i += oneunit(i)
133181
end
134-
values = basetype[i[2] for i in vals]
135-
if hasexpr && values != unique(values)
136-
throw(ArgumentError("values for Enum $typename are not unique"))
137-
end
138182
blk = quote
139183
# enum definition
140184
Base.@__doc__(primitive type $(esc(typename)) <: Enum{$(basetype)} $(sizeof(basetype) * 8) end)
141185
function $(esc(typename))(x::Integer)
142186
$(membershiptest(:x, values)) || enum_argument_error($(Expr(:quote, typename)), x)
143187
return bitcast($(esc(typename)), convert($(basetype), x))
144188
end
145-
Enums.basetype(::Type{$(esc(typename))}) = $(esc(basetype))
189+
Enums.namemap(::Type{$(esc(typename))}) = $(esc(namemap))
146190
Base.typemin(x::Type{$(esc(typename))}) = $(esc(typename))($lo)
147191
Base.typemax(x::Type{$(esc(typename))}) = $(esc(typename))($hi)
148-
Base.isless(x::$(esc(typename)), y::$(esc(typename))) = isless($basetype(x), $basetype(y))
149-
let insts = ntuple(i->$(esc(typename))($values[i]), $(length(vals)))
192+
let insts = ntuple(i->$(esc(typename))($values[i]), $(length(values)))
150193
Base.instances(::Type{$(esc(typename))}) = insts
151194
end
152-
function Base.print(io::IO, x::$(esc(typename)))
153-
for (sym, i) in $vals
154-
if i == $(basetype)(x)
155-
print(io, sym); break
156-
end
157-
end
158-
end
159-
function Base.show(io::IO, x::$(esc(typename)))
160-
if get(io, :compact, false)
161-
print(io, x)
162-
else
163-
print(io, x, "::")
164-
show(IOContext(io, :compact => true), typeof(x))
165-
print(io, " = ")
166-
show(io, $basetype(x))
167-
end
168-
end
169-
function Base.show(io::IO, ::MIME"text/plain", t::Type{$(esc(typename))})
170-
print(io, "Enum ")
171-
Base.show_datatype(io, t)
172-
print(io, ":")
173-
for (sym, i) in $vals
174-
print(io, "\n", sym, " = ")
175-
show(io, i)
176-
end
177-
end
178195
end
179196
if isa(typename, Symbol)
180-
for (sym,i) in vals
197+
for (i, sym) in namemap
181198
push!(blk.args, :(const $(esc(sym)) = $(esc(typename))($i)))
182199
end
183200
end

base/abstractarraymath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ julia> selectdim(A, 2, 3)
121121
"""
122122
@inline selectdim(A::AbstractArray, d::Integer, i) = _selectdim(A, d, i, setindex(map(Slice, axes(A)), i, d))
123123
@noinline function _selectdim(A, d, i, idxs)
124-
d >= 1 || throw(ArgumentError("dimension must be ≥ 1"))
124+
d >= 1 || throw(ArgumentError("dimension must be ≥ 1, got $d"))
125125
nd = ndims(A)
126126
d > nd && (i == 1 || throw(BoundsError(A, (ntuple(k->Colon(),d-1)..., i))))
127127
return view(A, idxs...)

base/arrayshow.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ _show_empty(io, X) = nothing # by default, we don't know this constructor
417417
function show(io::IO, X::AbstractArray)
418418
ndims(X) == 1 && return show_vector(io, X)
419419
prefix = typeinfo_prefix(io, X)
420-
io = IOContext(io, :typeinfo => eltype(X), :compact => get(io, :compact, true))
420+
io = IOContext(io, :typeinfo => eltype(X))
421421
isempty(X) ?
422422
_show_empty(io, X) :
423423
_show_nonempty(io, X, prefix)
@@ -431,7 +431,7 @@ end
431431
function show_vector(io::IO, v, opn='[', cls=']')
432432
print(io, typeinfo_prefix(io, v))
433433
# directly or indirectly, the context now knows about eltype(v)
434-
io = IOContext(io, :typeinfo => eltype(v), :compact => get(io, :compact, true))
434+
io = IOContext(io, :typeinfo => eltype(v))
435435
limited = get(io, :limit, false)
436436
if limited && length(v) > 20
437437
inds = axes1(v)

base/boot.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@
9090
#end
9191

9292
#struct LineInfoNode
93-
# mod::Module
94-
# method::Symbol
93+
# method::Any
9594
# file::Symbol
9695
# line::Int
9796
# inlined_at::Int
@@ -375,8 +374,8 @@ eval(Core, :(PiNode(val, typ) = $(Expr(:new, :PiNode, :val, :typ))))
375374
eval(Core, :(PhiCNode(values::Array{Any, 1}) = $(Expr(:new, :PhiCNode, :values))))
376375
eval(Core, :(UpsilonNode(val) = $(Expr(:new, :UpsilonNode, :val))))
377376
eval(Core, :(UpsilonNode() = $(Expr(:new, :UpsilonNode))))
378-
eval(Core, :(LineInfoNode(mod::Module, method::Symbol, file::Symbol, line::Int, inlined_at::Int) =
379-
$(Expr(:new, :LineInfoNode, :mod, :method, :file, :line, :inlined_at))))
377+
eval(Core, :(LineInfoNode(@nospecialize(method), file::Symbol, line::Int, inlined_at::Int) =
378+
$(Expr(:new, :LineInfoNode, :method, :file, :line, :inlined_at))))
380379

381380
Module(name::Symbol=:anonymous, std_imports::Bool=true) = ccall(:jl_f_new_module, Ref{Module}, (Any, Bool), name, std_imports)
382381

base/compiler/inferencestate.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mutable struct InferenceState
5858
s_types = Any[ nothing for i = 1:n ]
5959

6060
# initial types
61-
nslots = length(src.slotnames)
61+
nslots = length(src.slotflags)
6262
argtypes = result.argtypes
6363
nargs = length(argtypes)
6464
s_argtypes = VarTable(undef, nslots)
@@ -122,7 +122,7 @@ end
122122

123123
function sptypes_from_meth_instance(linfo::MethodInstance)
124124
toplevel = !isa(linfo.def, Method)
125-
if !toplevel && isempty(linfo.sparam_vals) && !isempty(linfo.def.sparam_syms)
125+
if !toplevel && isempty(linfo.sparam_vals) && isa(linfo.def.sig, UnionAll)
126126
# linfo is unspecialized
127127
sp = Any[]
128128
sig = linfo.def.sig

base/compiler/optimize.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ mutable struct OptimizationState
3737
if nssavalues isa Int
3838
src.ssavaluetypes = Any[ Any for i = 1:nssavalues ]
3939
end
40-
nslots = length(src.slotnames)
41-
slottypes = Any[ Any for i = 1:nslots ]
40+
nslots = length(src.slotflags)
41+
slottypes = src.slottypes
42+
if slottypes === nothing
43+
slottypes = Any[ Any for i = 1:nslots ]
44+
end
4245
s_edges = []
4346
# cache some useful state computations
4447
toplevel = !isa(linfo.def, Method)
@@ -73,7 +76,7 @@ end
7376
# This is implied by `SLOT_USEDUNDEF`.
7477
# If this is not set, all the uses are (statically) dominated by the defs.
7578
# In particular, if a slot has `AssignedOnce && !StaticUndef`, it is an SSA.
76-
const SLOT_STATICUNDEF = 1
79+
const SLOT_STATICUNDEF = 1 # slot might be used before it is defined (structurally)
7780
const SLOT_ASSIGNEDONCE = 16 # slot is assigned to only once
7881
const SLOT_USEDUNDEF = 32 # slot has uses that might raise UndefVarError
7982
# const SLOT_CALLED = 64
@@ -260,6 +263,9 @@ function is_pure_intrinsic_infer(f::IntrinsicFunction)
260263
f === Intrinsics.cglobal) # cglobal lookup answer changes at runtime
261264
end
262265

266+
# whether `f` is effect free if nothrow
267+
intrinsic_effect_free_if_nothrow(f) = f === Intrinsics.pointerref || is_pure_intrinsic_infer(f)
268+
263269
## Computing the cost of a function body
264270

265271
# saturating sum (inputs are nonnegative), prevents overflow with typemax(Int) below

base/compiler/ssair/driver.jl

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

33
using Core: LineInfoNode
4-
const NullLineInfo = LineInfoNode(@__MODULE__, Symbol(""), Symbol(""), 0, 0)
54

65
if false
76
import Base: Base, @show
@@ -103,8 +102,7 @@ function just_construct_ssa(ci::CodeInfo, code::Vector{Any}, nargs::Int, sv::Opt
103102
defuse_insts = scan_slot_def_use(nargs, ci, code)
104103
@timeit "domtree 1" domtree = construct_domtree(cfg)
105104
ir = let code = Any[nothing for _ = 1:length(code)]
106-
argtypes = sv.slottypes[1:(nargs+1)]
107-
IRCode(code, Any[], ci.codelocs, flags, cfg, collect(LineInfoNode, ci.linetable), argtypes, meta, sv.sptypes)
105+
IRCode(code, Any[], ci.codelocs, flags, cfg, collect(LineInfoNode, ci.linetable), sv.slottypes, meta, sv.sptypes)
108106
end
109107
@timeit "construct_ssa" ir = construct_ssa!(ci, code, ir, domtree, defuse_insts, nargs, sv.sptypes, sv.slottypes)
110108
return ir

0 commit comments

Comments
 (0)