Skip to content

Commit fe2311a

Browse files
authored
Merge pull request #39614 from JuliaLang/backports-release-1.6
Backports for 1.6-RC2
2 parents a58bdd9 + f731fbb commit fe2311a

File tree

117 files changed

+1816
-838
lines changed

Some content is hidden

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

117 files changed

+1816
-838
lines changed

Make.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,9 +1556,11 @@ endif
15561556
LIBGCC_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/$(LIBGCC_NAME))
15571557
LIBGCC_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBGCC_NAME))
15581558

1559-
# USE_SYSTEM_LIBM causes it to get symlinked into build_private_shlibdir
1559+
# USE_SYSTEM_LIBM and USE_SYSTEM_OPENLIBM causes it to get symlinked into build_private_shlibdir
15601560
ifeq ($(USE_SYSTEM_LIBM),1)
15611561
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
1562+
else ifeq ($(USE_SYSTEM_OPENLIBM),1)
1563+
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
15621564
else
15631565
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
15641566
endif

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,16 @@ else ifneq (,$(findstring $(OS),Linux FreeBSD))
344344
done
345345
endif
346346

347-
# Overwrite JL_SYSTEM_IMAGE_PATH in julia library
348-
if [ $(DARWIN_FRAMEWORK) = 0 ]; then \
349-
RELEASE_TARGET=$(DESTDIR)$(libdir)/libjulia.$(SHLIB_EXT); \
350-
DEBUG_TARGET=$(DESTDIR)$(libdir)/libjulia-debug.$(SHLIB_EXT); \
347+
# Overwrite JL_SYSTEM_IMAGE_PATH in libjulia-internal
348+
if [ "$(DARWIN_FRAMEWORK)" = "0" ]; then \
349+
RELEASE_TARGET=$(DESTDIR)$(private_libdir)/libjulia-internal.$(SHLIB_EXT); \
350+
DEBUG_TARGET=$(DESTDIR)$(private_libdir)/libjulia-internal-debug.$(SHLIB_EXT); \
351351
else \
352352
RELEASE_TARGET=$(DESTDIR)$(prefix)/$(framework_dylib); \
353353
DEBUG_TARGET=$(DESTDIR)$(prefix)/$(framework_dylib)_debug; \
354354
fi; \
355355
$(call stringreplace,$${RELEASE_TARGET},sys.$(SHLIB_EXT)$$,$(private_libdir_rel)/sys.$(SHLIB_EXT)); \
356-
if [ $(BUNDLE_DEBUG_LIBS) = 1 ]; then \
356+
if [ "$(BUNDLE_DEBUG_LIBS)" = "1" ]; then \
357357
$(call stringreplace,$${DEBUG_TARGET},sys-debug.$(SHLIB_EXT)$$,$(private_libdir_rel)/sys-debug.$(SHLIB_EXT)); \
358358
fi;
359359
endif

base/abstractarray.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ end
394394
Get the first `n` elements of the iterable collection `itr`, or fewer elements if `v` is not
395395
long enough.
396396
397+
!!! compat "Julia 1.6"
398+
This method requires at least Julia 1.6.
399+
397400
# Examples
398401
```jldoctest
399402
julia> first(["foo", "bar", "qux"], 2)
@@ -439,6 +442,9 @@ last(a) = a[end]
439442
Get the last `n` elements of the iterable collection `itr`, or fewer elements if `v` is not
440443
long enough.
441444
445+
!!! compat "Julia 1.6"
446+
This method requires at least Julia 1.6.
447+
442448
# Examples
443449
```jldoctest
444450
julia> last(["foo", "bar", "qux"], 2)

base/arrayshow.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,9 @@ function _show_nonempty(io::IO, X::AbstractMatrix, prefix::String)
385385
indr, indc = axes(X,1), axes(X,2)
386386
nr, nc = length(indr), length(indc)
387387
rdots, cdots = false, false
388-
rr1, rr2 = UnitRange{Int}(indr), 1:0
389-
cr1, cr2 = UnitRange{Int}(indc), 1:0
388+
rr1, rr2 = unitrange(indr), 1:0
389+
cr1 = unitrange(indc)
390+
cr2 = first(cr1) .+ (0:-1)
390391
if limit
391392
if nr > 4
392393
rr1, rr2 = rr1[1:2], rr1[nr-1:nr]
@@ -417,7 +418,7 @@ function _show_nonempty(io::IO, X::AbstractMatrix, prefix::String)
417418
end
418419
end
419420
end
420-
last(rr) != nr && rdots && print(io, "\u2026 ; ")
421+
last(rr) != last(indr) && rdots && print(io, "\u2026 ; ")
421422
end
422423
print(io, "]")
423424
end

base/bitarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ gen_bitarrayN(::Type{BitVector}, itsz, itr) = gen_bitarra
605605
gen_bitarrayN(::Type{BitVector}, itsz::HasShape{1}, itr) = gen_bitarray(itsz, itr)
606606
gen_bitarrayN(::Type{BitArray{N}}, itsz::HasShape{N}, itr) where N = gen_bitarray(itsz, itr)
607607
# The first of these is just for ambiguity resolution
608-
gen_bitarrayN(::Type{BitVector}, itsz::HasShape{N}, itr) where N = throw(DimensionMismatch("cannot create a $T from a $N-dimensional iterator"))
608+
gen_bitarrayN(::Type{BitVector}, itsz::HasShape{N}, itr) where N = throw(DimensionMismatch("cannot create a BitVector from a $N-dimensional iterator"))
609609
gen_bitarrayN(@nospecialize(T::Type), itsz::HasShape{N}, itr) where N = throw(DimensionMismatch("cannot create a $T from a $N-dimensional iterator"))
610610
gen_bitarrayN(@nospecialize(T::Type), itsz, itr) = throw(DimensionMismatch("cannot create a $T from a generic iterator"))
611611

base/boot.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,4 +800,7 @@ Integer(x::Union{Float16, Float32, Float64}) = Int(x)
800800
# The internal jl_parse which will call into Core._parse if not `nothing`.
801801
_parse = nothing
802802

803+
# support for deprecated uses of internal _apply function
804+
_apply(x...) = Core._apply_iterate(Main.Base.iterate, x...)
805+
803806
ccall(:jl_set_istopmod, Cvoid, (Any, Bool), Core, true)

base/cmd.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ setenv(cmd::Cmd; dir="") = Cmd(cmd; dir=dir)
251251
Merge new environment mappings into the given `Cmd` object, returning a new `Cmd` object.
252252
Duplicate keys are replaced. If `command` does not contain any environment values set already,
253253
it inherits the current environment at time of `addenv()` call if `inherit` is `true`.
254+
255+
!!! compat "Julia 1.6"
256+
This function requires Julia 1.6 or later.
254257
"""
255258
function addenv(cmd::Cmd, env::Dict; inherit::Bool = true)
256259
new_env = Dict{String,String}()

base/compiler/abstractinterpretation.jl

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ function abstract_call_method(interp::AbstractInterpreter, method::Method, @nosp
434434
# Under direct self-recursion, permit much greater use of reducers.
435435
# here we assume that complexity(specTypes) :>= complexity(sig)
436436
comparison = sv.linfo.specTypes
437-
l_comparison = length(unwrap_unionall(comparison).parameters)
437+
l_comparison = length(unwrap_unionall(comparison).parameters)::Int
438438
spec_len = max(spec_len, l_comparison)
439439
else
440440
comparison = method.sig
@@ -589,13 +589,7 @@ end
589589

590590
# simulate iteration protocol on container type up to fixpoint
591591
function abstract_iteration(interp::AbstractInterpreter, @nospecialize(itft), @nospecialize(itertype), sv::InferenceState)
592-
if !isdefined(Main, :Base) || !isdefined(Main.Base, :iterate) || !isconst(Main.Base, :iterate)
593-
return Any[Vararg{Any}], nothing
594-
end
595-
if itft === nothing
596-
iteratef = getfield(Main.Base, :iterate)
597-
itft = Const(iteratef)
598-
elseif isa(itft, Const)
592+
if isa(itft, Const)
599593
iteratef = itft.val
600594
else
601595
return Any[Vararg{Any}], nothing
@@ -607,6 +601,7 @@ function abstract_iteration(interp::AbstractInterpreter, @nospecialize(itft), @n
607601
# Return Bottom if this is not an iterator.
608602
# WARNING: Changes to the iteration protocol must be reflected here,
609603
# this is not just an optimization.
604+
# TODO: this doesn't realize that Array, SimpleVector, Tuple, and NamedTuple do not use the iterate protocol
610605
stateordonet === Bottom && return Any[Bottom], AbstractIterationInfo(CallMeta[CallMeta(Bottom, info)])
611606
valtype = statetype = Bottom
612607
ret = Any[]
@@ -670,7 +665,7 @@ function abstract_apply(interp::AbstractInterpreter, @nospecialize(itft), @nospe
670665
aftw = widenconst(aft)
671666
if !isa(aft, Const) && (!isType(aftw) || has_free_typevars(aftw))
672667
if !isconcretetype(aftw) || (aftw <: Builtin)
673-
add_remark!(interp, sv, "Core._apply called on a function of a non-concrete type")
668+
add_remark!(interp, sv, "Core._apply_iterate called on a function of a non-concrete type")
674669
# bail now, since it seems unlikely that abstract_call will be able to do any better after splitting
675670
# this also ensures we don't call abstract_call_gf_by_type below on an IntrinsicFunction or Builtin
676671
return CallMeta(Any, false)
@@ -679,16 +674,20 @@ function abstract_apply(interp::AbstractInterpreter, @nospecialize(itft), @nospe
679674
res = Union{}
680675
nargs = length(aargtypes)
681676
splitunions = 1 < unionsplitcost(aargtypes) <= InferenceParams(interp).MAX_APPLY_UNION_ENUM
682-
ctypes = Any[Any[aft]]
677+
ctypes = [Any[aft]]
683678
infos = [Union{Nothing, AbstractIterationInfo}[]]
684679
for i = 1:nargs
685-
ctypes´ = []
686-
infos′ = []
680+
ctypes´ = Vector{Any}[]
681+
infos′ = Vector{Union{Nothing, AbstractIterationInfo}}[]
687682
for ti in (splitunions ? uniontypes(aargtypes[i]) : Any[aargtypes[i]])
688683
if !isvarargtype(ti)
689-
cti, info = precise_container_type(interp, itft, ti, sv)
684+
cti_info = precise_container_type(interp, itft, ti, sv)
685+
cti = cti_info[1]::Vector{Any}
686+
info = cti_info[2]::Union{Nothing,AbstractIterationInfo}
690687
else
691-
cti, info = precise_container_type(interp, itft, unwrapva(ti), sv)
688+
cti_info = precise_container_type(interp, itft, unwrapva(ti), sv)
689+
cti = cti_info[1]::Vector{Any}
690+
info = cti_info[2]::Union{Nothing,AbstractIterationInfo}
692691
# We can't represent a repeating sequence of the same types,
693692
# so tmerge everything together to get one type that represents
694693
# everything.
@@ -705,7 +704,7 @@ function abstract_apply(interp::AbstractInterpreter, @nospecialize(itft), @nospe
705704
continue
706705
end
707706
for j = 1:length(ctypes)
708-
ct = ctypes[j]
707+
ct = ctypes[j]::Vector{Any}
709708
if isvarargtype(ct[end])
710709
# This is vararg, we're not gonna be able to do any inling,
711710
# drop the info
@@ -826,7 +825,8 @@ function abstract_call_builtin(interp::AbstractInterpreter, f::Builtin, fargs::U
826825
end
827826
rt = builtin_tfunction(interp, f, argtypes[2:end], sv)
828827
if f === getfield && isa(fargs, Vector{Any}) && la == 3 && isa(argtypes[3], Const) && isa(argtypes[3].val, Int) && argtypes[2] Tuple
829-
cti, _ = precise_container_type(interp, nothing, argtypes[2], sv)
828+
# TODO: why doesn't this use the getfield_tfunc?
829+
cti, _ = precise_container_type(interp, iterate, argtypes[2], sv)
830830
idx = argtypes[3].val::Int
831831
if 1 <= idx <= length(cti)
832832
rt = unwrapva(cti[idx])
@@ -945,11 +945,7 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
945945
la = length(argtypes)
946946

947947
if isa(f, Builtin)
948-
if f === _apply
949-
ft = argtype_by_index(argtypes, 2)
950-
ft === Bottom && return CallMeta(Bottom, false)
951-
return abstract_apply(interp, nothing, ft, argtype_tail(argtypes, 3), sv, max_methods)
952-
elseif f === _apply_iterate
948+
if f === _apply_iterate
953949
itft = argtype_by_index(argtypes, 2)
954950
ft = argtype_by_index(argtypes, 3)
955951
(itft === Bottom || ft === Bottom) && return CallMeta(Bottom, false)
@@ -1304,6 +1300,28 @@ function abstract_eval_ssavalue(s::SSAValue, src::CodeInfo)
13041300
return typ
13051301
end
13061302

1303+
function widenreturn(@nospecialize rt)
1304+
# only propagate information we know we can store
1305+
# and is valid and good inter-procedurally
1306+
rt = widenconditional(rt)
1307+
isa(rt, Const) && return rt
1308+
isa(rt, Type) && return rt
1309+
if isa(rt, PartialStruct)
1310+
fields = copy(rt.fields)
1311+
haveconst = false
1312+
for i in 1:length(fields)
1313+
a = widenreturn(fields[i])
1314+
if !haveconst && has_const_info(a)
1315+
# TODO: consider adding && const_prop_profitable(a) here?
1316+
haveconst = true
1317+
end
1318+
fields[i] = a
1319+
end
1320+
haveconst && return PartialStruct(rt.typ, fields)
1321+
end
1322+
return widenconst(rt)
1323+
end
1324+
13071325
# make as much progress on `frame` as possible (without handling cycles)
13081326
function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
13091327
@assert !frame.inferred
@@ -1326,6 +1344,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
13261344
frame.currpc = pc
13271345
frame.cur_hand = frame.handler_at[pc]
13281346
frame.stmt_edges[pc] === nothing || empty!(frame.stmt_edges[pc])
1347+
frame.stmt_info[pc] = nothing
13291348
stmt = frame.src.code[pc]
13301349
changes = s[pc]::VarTable
13311350
t = nothing
@@ -1338,7 +1357,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
13381357
elseif isa(stmt, GotoNode)
13391358
pc´ = (stmt::GotoNode).label
13401359
elseif isa(stmt, GotoIfNot)
1341-
condt = abstract_eval_value(interp, stmt.cond, s[pc], frame)
1360+
condt = abstract_eval_value(interp, stmt.cond, changes, frame)
13421361
if condt === Bottom
13431362
empty!(frame.pclimitations)
13441363
break
@@ -1369,7 +1388,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
13691388
end
13701389
end
13711390
newstate_else = stupdate!(s[l], changes_else)
1372-
if newstate_else !== false
1391+
if newstate_else !== nothing
13731392
# add else branch to active IP list
13741393
if l < frame.pc´´
13751394
frame.pc´´ = l
@@ -1380,12 +1399,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
13801399
end
13811400
elseif isa(stmt, ReturnNode)
13821401
pc´ = n + 1
1383-
rt = widenconditional(abstract_eval_value(interp, stmt.val, s[pc], frame))
1384-
if !isa(rt, Const) && !isa(rt, Type) && !isa(rt, PartialStruct)
1385-
# only propagate information we know we can store
1386-
# and is valid inter-procedurally
1387-
rt = widenconst(rt)
1388-
end
1402+
rt = widenreturn(abstract_eval_value(interp, stmt.val, changes, frame))
13891403
# copy limitations to return value
13901404
if !isempty(frame.pclimitations)
13911405
union!(frame.limitations, frame.pclimitations)
@@ -1414,9 +1428,8 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
14141428
frame.cur_hand = Pair{Any,Any}(l, frame.cur_hand)
14151429
# propagate type info to exception handler
14161430
old = s[l]
1417-
new = s[pc]::Array{Any,1}
1418-
newstate_catch = stupdate!(old, new)
1419-
if newstate_catch !== false
1431+
newstate_catch = stupdate!(old, changes)
1432+
if newstate_catch !== nothing
14201433
if l < frame.pc´´
14211434
frame.pc´´ = l
14221435
end
@@ -1483,12 +1496,12 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
14831496
# (such as a terminator for a loop, if-else, or try block),
14841497
# consider whether we should jump to an older backedge first,
14851498
# to try to traverse the statements in approximate dominator order
1486-
if newstate !== false
1499+
if newstate !== nothing
14871500
s[pc´] = newstate
14881501
end
14891502
push!(W, pc´)
14901503
pc = frame.pc´´
1491-
elseif newstate !== false
1504+
elseif newstate !== nothing
14921505
s[pc´] = newstate
14931506
pc = pc´
14941507
elseif pc´ in W

base/compiler/compiler.jl

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

3-
getfield(getfield(Main, :Core), :eval)(getfield(Main, :Core), :(baremodule Compiler
3+
getfield(Core, :eval)(Core, :(baremodule Compiler
44

55
using Core.Intrinsics, Core.IR
66

77
import Core: print, println, show, write, unsafe_write, stdout, stderr,
8-
_apply, _apply_iterate, svec, apply_type, Builtin, IntrinsicFunction,
8+
_apply_iterate, svec, apply_type, Builtin, IntrinsicFunction,
99
MethodInstance, CodeInstance, MethodMatch
1010

1111
const getproperty = Core.getfield

base/compiler/optimize.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,19 +326,19 @@ function statement_cost(ex::Expr, line::Int, src::CodeInfo, sptypes::Vector{Any}
326326
# The efficiency of operations like a[i] and s.b
327327
# depend strongly on whether the result can be
328328
# inferred, so check the type of ex
329-
if f === Main.Core.getfield || f === Main.Core.tuple
329+
if f === Core.getfield || f === Core.tuple
330330
# we might like to penalize non-inferrability, but
331331
# tuple iteration/destructuring makes that impossible
332332
# return plus_saturate(argcost, isknowntype(extyp) ? 1 : params.inline_nonleaf_penalty)
333333
return 0
334-
elseif f === Main.Core.isa
334+
elseif f === Core.isa
335335
# If we're in a union context, we penalize type computations
336336
# on union types. In such cases, it is usually better to perform
337337
# union splitting on the outside.
338338
if union_penalties && isa(argextype(ex.args[2], src, sptypes, slottypes), Union)
339339
return params.inline_nonleaf_penalty
340340
end
341-
elseif (f === Main.Core.arrayref || f === Main.Core.const_arrayref) && length(ex.args) >= 3
341+
elseif (f === Core.arrayref || f === Core.const_arrayref) && length(ex.args) >= 3
342342
atyp = argextype(ex.args[3], src, sptypes, slottypes)
343343
return isknowntype(atyp) ? 4 : error_path ? params.inline_error_path_cost : params.inline_nonleaf_penalty
344344
end
@@ -371,7 +371,7 @@ function statement_cost(ex::Expr, line::Int, src::CodeInfo, sptypes::Vector{Any}
371371
end
372372
a = ex.args[2]
373373
if a isa Expr
374-
cost = plus_saturate(cost, statement_cost(a, -1, src, sptypes, slottypes, params, error_path))
374+
cost = plus_saturate(cost, statement_cost(a, -1, src, sptypes, slottypes, union_penalties, params, error_path))
375375
end
376376
return cost
377377
elseif head === :copyast
@@ -392,7 +392,7 @@ function statement_or_branch_cost(@nospecialize(stmt), line::Int, src::CodeInfo,
392392
thiscost = 0
393393
if stmt isa Expr
394394
thiscost = statement_cost(stmt, line, src, sptypes, slottypes, union_penalties, params,
395-
params.unoptimize_throw_blocks && line in throw_blocks)::Int
395+
throw_blocks !== nothing && line in throw_blocks)::Int
396396
elseif stmt isa GotoNode
397397
# loops are generally always expensive
398398
# but assume that forward jumps are already counted for from

base/compiler/ssair/driver.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ function convert_to_ircode(ci::CodeInfo, code::Vector{Any}, coverage::Bool, narg
4343
labelmap = coverage ? fill(0, length(code)) : changemap
4444
prevloc = zero(eltype(ci.codelocs))
4545
stmtinfo = sv.stmt_info
46+
ssavaluetypes = ci.ssavaluetypes::Vector{Any}
4647
while idx <= length(code)
4748
codeloc = ci.codelocs[idx]
4849
if coverage && codeloc != prevloc && codeloc != 0
4950
# insert a side-effect instruction before the current instruction in the same basic block
5051
insert!(code, idx, Expr(:code_coverage_effect))
5152
insert!(ci.codelocs, idx, codeloc)
52-
insert!(ci.ssavaluetypes, idx, Nothing)
53+
insert!(ssavaluetypes, idx, Nothing)
5354
insert!(stmtinfo, idx, nothing)
5455
changemap[oldidx] += 1
5556
if oldidx < length(labelmap)
@@ -58,12 +59,12 @@ function convert_to_ircode(ci::CodeInfo, code::Vector{Any}, coverage::Bool, narg
5859
idx += 1
5960
prevloc = codeloc
6061
end
61-
if code[idx] isa Expr && ci.ssavaluetypes[idx] === Union{}
62+
if code[idx] isa Expr && ssavaluetypes[idx] === Union{}
6263
if !(idx < length(code) && isa(code[idx + 1], ReturnNode) && !isdefined((code[idx + 1]::ReturnNode), :val))
6364
# insert unreachable in the same basic block after the current instruction (splitting it)
6465
insert!(code, idx + 1, ReturnNode())
6566
insert!(ci.codelocs, idx + 1, ci.codelocs[idx])
66-
insert!(ci.ssavaluetypes, idx + 1, Union{})
67+
insert!(ssavaluetypes, idx + 1, Union{})
6768
insert!(stmtinfo, idx + 1, nothing)
6869
if oldidx < length(changemap)
6970
changemap[oldidx + 1] += 1

0 commit comments

Comments
 (0)