Skip to content

Commit f7295bf

Browse files
authored
Backports for 1.11.0-beta2 (#54112)
Backported PRs: - [x] #53665 <!-- use afoldl instead of tail recursion for tuples --> - [x] #53976 <!-- LinearAlgebra: LazyString in interpolated error messages --> - [x] #54005 <!-- make `view(::Memory, ::Colon)` produce a Vector --> - [x] #54010 <!-- Overload `Base.literal_pow` for `AbstractQ` --> - [x] #54069 <!-- Allow PrecompileTools to see MI's inferred by foreign abstract interpreters --> - [x] #53750 <!-- inference correctness: fields and globals can revert to undef --> - [x] #53984 <!-- Profile: fix heap snapshot is valid char check --> - [x] #54102 <!-- Explicitly compute stride in unaliascopy for SubArray --> - [x] #54070 <!-- Fix integer overflow in `skip(s::IOBuffer, typemax(Int64))` --> - [x] #54013 <!-- Support case-changes to Annotated{String,Char}s --> - [x] #53941 <!-- Fix writing of AnnotatedChars to AnnotatedIOBuffer --> - [x] #54137 <!-- Fix typo in docs for `partialsortperm` --> - [x] #54129 <!-- use correct size when creating output data from an IOBuffer --> - [x] #54153 <!-- Fixup IdSet docstring --> - [x] #54143 <!-- Fix `make install` from tarballs --> - [x] #54151 <!-- LinearAlgebra: Correct zero element in `_generic_matvecmul!` for block adj/trans --> - [x] #54213 <!-- Add `public` statement to `Base.GC` --> - [x] #54222 <!-- Utilize correct tbaa when emitting stores of unions. --> - [x] #54233 <!-- set MAX_OS_WRITE on unix --> - [x] #54255 <!-- fix `_checked_mul_dims` in the presence of 0s and overflow. --> - [x] #54259 <!-- Fix typo in `readuntil` --> - [x] #54251 <!-- fix typo in gc_mark_memory8 when chunking a large array --> - [x] #54276 <!-- Fix solve for complex `Hermitian` with non-vanishing imaginary part on diagonal --> - [x] #54248 <!-- ensure package callbacks are invoked when no valid precompile file exists for an "auto loaded" stdlib --> - [x] #54308 <!-- Implement eval-able AnnotatedString 2-arg show --> - [x] #54302 <!-- Specialised substring equality for annotated strs --> - [x] #54243 <!-- prevent `package_callbacks` to run multiple time for a single package --> - [x] #54350 <!-- add a precompile signature to Artifacts code that is used by JLLs --> - [x] #54331 <!-- correctly track freed bytes in jl_genericmemory_to_string --> - [x] #53509 <!-- revert moving "creating packages" from Pkg.jl --> - [x] #54335 <!-- When accessing the data pointer for an array, first decay it to a Derived Pointer --> - [x] #54239 <!-- Make sure `fieldcount` constant-folds for `Tuple{...}` --> - [x] #54288 - [x] #54067 - [x] #53715 <!-- Add read/write specialisation for IOContext{AnnIO} --> - [x] #54289 <!-- Rework annotation ordering/optimisations --> - [x] #53815 <!-- create phantom task for GC threads --> - [x] #54130 <!-- inference: handle `LimitedAccuracy` in `handle_global_assignment!` --> - [x] #54428 <!-- Move ConsoleLogging.jl into Base --> - [x] #54332 <!-- Revert "add unsetindex support to more copyto methods (#51760)" --> - [x] #53826 <!-- Make all command-line options documented in all related files --> - [x] #54465 <!-- typeintersect: conservative typevar subtitution during `finish_unionall` --> - [x] #54514 <!-- typeintersect: followup cleanup for the nothrow path of type instantiation --> - [x] #54499 <!-- make `@doc x` work without REPL loaded --> - [x] #54210 <!-- attach finalizer in `mmap` to the correct object --> - [x] #54359 <!-- Pkg REPL: cache `pkg_mode` lookup --> Non-merged PRs with backport label: - [ ] #54471 <!-- Actually setup jit targets when compiling packageimages instead of targeting only one --> - [ ] #54457 <!-- Make `String(::Memory)` copy --> - [ ] #54323 <!-- inference: fix too conservative effects for recursive cycles --> - [ ] #54322 <!-- effects: add new `@consistent_overlay` macro --> - [ ] #54191 <!-- make `AbstractPipe` public --> - [ ] #53957 <!-- tweak how filtering is done for what packages should be precompiled --> - [ ] #53882 <!-- Warn about cycles in extension precompilation --> - [ ] #53707 <!-- Make ScopedValue public --> - [ ] #53452 <!-- RFC: allow Tuple{Union{}}, returning Union{} --> - [ ] #53402 <!-- Add `jl_getaffinity` and `jl_setaffinity` --> - [ ] #53286 <!-- Raise an error when using `include_dependency` with non-existent file or directory --> - [ ] #52694 <!-- Reinstate similar for AbstractQ for backward compatibility --> - [ ] #51479 <!-- prevent code loading from lookin in the versioned environment when building Julia -->
2 parents 08e1fc0 + 4592b4b commit f7295bf

File tree

138 files changed

+2359
-2290
lines changed

Some content is hidden

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

138 files changed

+2359
-2290
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ $(foreach link,base $(JULIAHOME)/test,$(eval $(call symlink_target,$(link),$$(bu
6161
julia_flisp.boot.inc.phony: julia-deps
6262
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src julia_flisp.boot.inc.phony
6363

64+
# Build the HTML docs (skipped if already exists, notably in tarballs)
65+
$(BUILDROOT)/doc/_build/html/en/index.html: $(shell find $(BUILDROOT)/base $(BUILDROOT)/doc \( -path $(BUILDROOT)/doc/_build -o -path $(BUILDROOT)/doc/deps -o -name *_constants.jl -o -name *_h.jl -o -name version_git.jl \) -prune -o -type f -print)
66+
@$(MAKE) docs
67+
6468
julia-symlink: julia-cli-$(JULIA_BUILD_MODE)
6569
ifeq ($(OS),WINNT)
6670
echo '@"%~dp0/'"$$(echo '$(call rel_path,$(BUILDROOT),$(JULIA_EXECUTABLE))')"'" %*' | tr / '\\' > $(BUILDROOT)/julia.bat
@@ -272,7 +276,7 @@ define stringreplace
272276
endef
273277

274278

275-
install: $(build_depsbindir)/stringreplace docs
279+
install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html
276280
@$(MAKE) $(QUIET_MAKE) $(JULIA_BUILD_MODE)
277281
@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(private_libexecdir); do \
278282
mkdir -p $(DESTDIR)$$subdir; \
@@ -530,7 +534,7 @@ app:
530534
darwinframework:
531535
$(MAKE) -C $(JULIAHOME)/contrib/mac/framework
532536

533-
light-source-dist.tmp: docs
537+
light-source-dist.tmp: $(BUILDROOT)/doc/_build/html/en/index.html
534538
ifneq ($(BUILDROOT),$(JULIAHOME))
535539
$(error make light-source-dist does not work in out-of-tree builds)
536540
endif

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Compiler/Runtime improvements
4747
Command-line option changes
4848
---------------------------
4949

50-
* The entry point for Julia has been standardized to `Main.main(ARGS)`. This must be explicitly opted into using the `@main` macro
50+
* The entry point for Julia has been standardized to `Main.main(args)`. This must be explicitly opted into using the `@main` macro
5151
(see the docstring for further details). When opted-in, and `julia` is invoked to run a script or expression
5252
(i.e. using `julia script.jl` or `julia -e expr`), `julia` will subsequently run the `Main.main` function automatically.
5353
This is intended to unify script and compilation workflows, where code loading may happen

base/Base.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,11 @@ include("weakkeydict.jl")
401401
include("scopedvalues.jl")
402402
using .ScopedValues
403403

404+
# metaprogramming
405+
include("meta.jl")
406+
404407
# Logging
405-
include("logging.jl")
408+
include("logging/logging.jl")
406409
using .CoreLogging
407410

408411
include("env.jl")
@@ -494,9 +497,6 @@ include("irrationals.jl")
494497
include("mathconstants.jl")
495498
using .MathConstants: ℯ, π, pi
496499

497-
# metaprogramming
498-
include("meta.jl")
499-
500500
# Stack frames and traces
501501
include("stacktraces.jl")
502502
using .StackTraces
@@ -633,6 +633,8 @@ function __init__()
633633
if get_bool_env("JULIA_USE_FLISP_PARSER", false) === false
634634
JuliaSyntax.enable_in_core!()
635635
end
636+
637+
CoreLogging.global_logger(CoreLogging.ConsoleLogger())
636638
nothing
637639
end
638640

base/abstractarray.jl

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,45 +1078,28 @@ function copyto_unaliased!(deststyle::IndexStyle, dest::AbstractArray, srcstyle:
10781078
if srcstyle isa IndexLinear
10791079
# Single-index implementation
10801080
@inbounds for i in srcinds
1081-
if isassigned(src, i)
1082-
dest[i + Δi] = src[i]
1083-
else
1084-
_unsetindex!(dest, i + Δi)
1085-
end
1081+
dest[i + Δi] = src[i]
10861082
end
10871083
else
10881084
# Dual-index implementation
10891085
i = idf - 1
1090-
@inbounds for a in eachindex(src)
1091-
i += 1
1092-
if isassigned(src, a)
1093-
dest[i] = src[a]
1094-
else
1095-
_unsetindex!(dest, i)
1096-
end
1086+
@inbounds for a in src
1087+
dest[i+=1] = a
10971088
end
10981089
end
10991090
else
11001091
iterdest, itersrc = eachindex(dest), eachindex(src)
11011092
if iterdest == itersrc
11021093
# Shared-iterator implementation
1103-
@inbounds for I in iterdest
1104-
if isassigned(src, I)
1105-
dest[I] = src[I]
1106-
else
1107-
_unsetindex!(dest, I)
1108-
end
1094+
for I in iterdest
1095+
@inbounds dest[I] = src[I]
11091096
end
11101097
else
11111098
# Dual-iterator implementation
11121099
ret = iterate(iterdest)
1113-
@inbounds for a in itersrc
1100+
@inbounds for a in src
11141101
idx, state = ret::NTuple{2,Any}
1115-
if isassigned(src, a)
1116-
dest[idx] = src[a]
1117-
else
1118-
_unsetindex!(dest, idx)
1119-
end
1102+
dest[idx] = a
11201103
ret = iterate(iterdest, state)
11211104
end
11221105
end
@@ -1145,11 +1128,7 @@ function copyto!(dest::AbstractArray, dstart::Integer,
11451128
(checkbounds(Bool, srcinds, sstart) && checkbounds(Bool, srcinds, sstart+n-1)) || throw(BoundsError(src, sstart:sstart+n-1))
11461129
src′ = unalias(dest, src)
11471130
@inbounds for i = 0:n-1
1148-
if isassigned(src′, sstart+i)
1149-
dest[dstart+i] = src′[sstart+i]
1150-
else
1151-
_unsetindex!(dest, dstart+i)
1152-
end
1131+
dest[dstart+i] = src′[sstart+i]
11531132
end
11541133
return dest
11551134
end
@@ -1160,7 +1139,7 @@ function copy(a::AbstractArray)
11601139
end
11611140

11621141
function copyto!(B::AbstractVecOrMat{R}, ir_dest::AbstractRange{Int}, jr_dest::AbstractRange{Int},
1163-
A::AbstractVecOrMat{S}, ir_src::AbstractRange{Int}, jr_src::AbstractRange{Int}) where {R,S}
1142+
A::AbstractVecOrMat{S}, ir_src::AbstractRange{Int}, jr_src::AbstractRange{Int}) where {R,S}
11641143
if length(ir_dest) != length(ir_src)
11651144
throw(ArgumentError(LazyString("source and destination must have same size (got ",
11661145
length(ir_src)," and ",length(ir_dest),")")))
@@ -1473,20 +1452,7 @@ function _setindex!(::IndexCartesian, A::AbstractArray, v, I::Vararg{Int,M}) whe
14731452
r
14741453
end
14751454

1476-
function _unsetindex!(A::AbstractArray, i::Integer...)
1477-
@_propagate_inbounds_meta
1478-
_unsetindex!(A, map(to_index, i)...)
1479-
end
1480-
1481-
function _unsetindex!(A::AbstractArray{T}, i::Int...) where T
1482-
# this provides a fallback method which is a no-op if the element is already unassigned
1483-
# such that copying into an uninitialized object generally always will work,
1484-
# even if the specific custom array type has not implemented `_unsetindex!`
1485-
@inline
1486-
@boundscheck checkbounds(A, i...)
1487-
allocatedinline(T) || @inbounds(!isassigned(A, i...)) || throw(MethodError(_unsetindex!, (A, i...)))
1488-
return A
1489-
end
1455+
_unsetindex!(A::AbstractArray, i::Integer) = _unsetindex!(A, to_index(i))
14901456

14911457
"""
14921458
parent(A)
@@ -1650,13 +1616,15 @@ eltypeof(x::AbstractArray) = eltype(x)
16501616

16511617
promote_eltypeof() = error()
16521618
promote_eltypeof(v1) = eltypeof(v1)
1653-
promote_eltypeof(v1, vs...) = promote_type(eltypeof(v1), promote_eltypeof(vs...))
1619+
promote_eltypeof(v1, v2) = promote_type(eltypeof(v1), eltypeof(v2))
1620+
promote_eltypeof(v1, v2, vs...) = (@inline; afoldl(((::Type{T}, y) where {T}) -> promote_type(T, eltypeof(y)), promote_eltypeof(v1, v2), vs...))
16541621
promote_eltypeof(v1::T, vs::T...) where {T} = eltypeof(v1)
16551622
promote_eltypeof(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T
16561623

16571624
promote_eltype() = error()
16581625
promote_eltype(v1) = eltype(v1)
1659-
promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...))
1626+
promote_eltype(v1, v2) = promote_type(eltype(v1), eltype(v2))
1627+
promote_eltype(v1, v2, vs...) = (@inline; afoldl(((::Type{T}, y) where {T}) -> promote_type(T, eltype(y)), promote_eltype(v1, v2), vs...))
16601628
promote_eltype(v1::T, vs::T...) where {T} = eltype(T)
16611629
promote_eltype(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T
16621630

base/array.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,7 @@ function _unsetindex!(A::Array, i::Int)
219219
@inbounds _unsetindex!(GenericMemoryRef(A.ref, i))
220220
return A
221221
end
222-
function _unsetindex!(A::Array, i::Int...)
223-
@inline
224-
@boundscheck checkbounds(A, i...)
225-
@inbounds _unsetindex!(A, _to_linear_index(A, i...))
226-
return A
227-
end
222+
228223

229224
# TODO: deprecate this (aligned_sizeof and/or elsize and/or sizeof(Some{T}) are more correct)
230225
elsize(::Type{A}) where {T,A<:Array{T}} = aligned_sizeof(T)

base/boot.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -547,19 +547,22 @@ function _checked_mul_dims(m::Int, n::Int)
547547
return a, ovflw
548548
end
549549
function _checked_mul_dims(m::Int, d::Int...)
550-
@_foldable_meta # the compiler needs to know this loop terminates
551-
a = m
552-
i = 1
553-
ovflw = false
554-
while Intrinsics.sle_int(i, nfields(d))
555-
di = getfield(d, i)
556-
b = Intrinsics.checked_smul_int(a, di)
557-
ovflw = Intrinsics.or_int(ovflw, getfield(b, 2))
558-
ovflw = Intrinsics.or_int(ovflw, Intrinsics.ule_int(typemax_Int, di))
559-
a = getfield(b, 1)
560-
i = Intrinsics.add_int(i, 1)
550+
@_foldable_meta # the compiler needs to know this loop terminates
551+
a = m
552+
i = 1
553+
ovflw = false
554+
neg = Intrinsics.ule_int(typemax_Int, m)
555+
zero = false # if m==0 we won't have overflow since we go left to right
556+
while Intrinsics.sle_int(i, nfields(d))
557+
di = getfield(d, i)
558+
b = Intrinsics.checked_smul_int(a, di)
559+
zero = Intrinsics.or_int(zero, di === 0)
560+
ovflw = Intrinsics.or_int(ovflw, getfield(b, 2))
561+
neg = Intrinsics.or_int(neg, Intrinsics.ule_int(typemax_Int, di))
562+
a = getfield(b, 1)
563+
i = Intrinsics.add_int(i, 1)
561564
end
562-
return a, ovflw
565+
return a, Intrinsics.or_int(neg, Intrinsics.and_int(ovflw, Intrinsics.not_int(zero)))
563566
end
564567

565568
# convert a set of dims to a length, with overflow checking

base/client.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function exec_options(opts)
260260
# Load Distributed module only if any of the Distributed options have been specified.
261261
distributed_mode = (opts.worker == 1) || (opts.nprocs > 0) || (opts.machine_file != C_NULL)
262262
if distributed_mode
263-
let Distributed = require_stdlib(PkgId(UUID((0x8ba89e20_285c_5b6f, 0x9357_94700520ee1b)), "Distributed"))
263+
let Distributed = require(PkgId(UUID((0x8ba89e20_285c_5b6f, 0x9357_94700520ee1b)), "Distributed"))
264264
Core.eval(MainInclude, :(const Distributed = $Distributed))
265265
Core.eval(Main, :(using Base.MainInclude.Distributed))
266266
end
@@ -575,7 +575,7 @@ The `@main` macro may be used standalone or as part of the function definition,
575575
case, parentheses are required. In particular, the following are equivalent:
576576
577577
```
578-
function (@main)(ARGS)
578+
function (@main)(args)
579579
println("Hello World")
580580
end
581581
```
@@ -594,7 +594,7 @@ imported into `Main`, it will be treated as an entrypoint in `Main`:
594594
```
595595
module MyApp
596596
export main
597-
(@main)(ARGS) = println("Hello World")
597+
(@main)(args) = println("Hello World")
598598
end
599599
using .MyApp
600600
# `julia` Will execute MyApp.main at the conclusion of script execution
@@ -604,7 +604,7 @@ Note that in particular, the semantics do not attach to the method
604604
or the name:
605605
```
606606
module MyApp
607-
(@main)(ARGS) = println("Hello World")
607+
(@main)(args) = println("Hello World")
608608
end
609609
const main = MyApp.main
610610
# `julia` Will *NOT* execute MyApp.main unless there is a separate `@main` annotation in `Main`

base/compiler/abstractinterpretation.jl

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,26 +2574,19 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
25742574
t = Bool
25752575
effects = EFFECTS_TOTAL
25762576
exct = Union{}
2577+
isa(sym, Symbol) && (sym = GlobalRef(frame_module(sv), sym))
25772578
if isa(sym, SlotNumber) && vtypes !== nothing
25782579
vtyp = vtypes[slot_id(sym)]
25792580
if vtyp.typ === Bottom
25802581
t = Const(false) # never assigned previously
25812582
elseif !vtyp.undef
25822583
t = Const(true) # definitely assigned previously
25832584
end
2584-
elseif isa(sym, Symbol)
2585-
if isdefined(frame_module(sv), sym)
2586-
t = Const(true)
2587-
elseif InferenceParams(interp).assume_bindings_static
2588-
t = Const(false)
2589-
else
2590-
effects = Effects(EFFECTS_TOTAL; consistent=ALWAYS_FALSE)
2591-
end
25922585
elseif isa(sym, GlobalRef)
2593-
if isdefined(sym.mod, sym.name)
2586+
if InferenceParams(interp).assume_bindings_static
2587+
t = Const(isdefined_globalref(sym))
2588+
elseif isdefinedconst_globalref(sym)
25942589
t = Const(true)
2595-
elseif InferenceParams(interp).assume_bindings_static
2596-
t = Const(false)
25972590
else
25982591
effects = Effects(EFFECTS_TOTAL; consistent=ALWAYS_FALSE)
25992592
end
@@ -2782,9 +2775,10 @@ function override_effects(effects::Effects, override::EffectsOverride)
27822775
end
27832776

27842777
isdefined_globalref(g::GlobalRef) = !iszero(ccall(:jl_globalref_boundp, Cint, (Any,), g))
2778+
isdefinedconst_globalref(g::GlobalRef) = isconst(g) && isdefined_globalref(g)
27852779

27862780
function abstract_eval_globalref_type(g::GlobalRef)
2787-
if isdefined_globalref(g) && isconst(g)
2781+
if isdefinedconst_globalref(g)
27882782
return Const(ccall(:jl_get_globalref_value, Any, (Any,), g))
27892783
end
27902784
ty = ccall(:jl_get_binding_type, Any, (Any, Any), g.mod, g.name)
@@ -2803,18 +2797,22 @@ function abstract_eval_globalref(interp::AbstractInterpreter, g::GlobalRef, sv::
28032797
if is_mutation_free_argtype(rt)
28042798
inaccessiblememonly = ALWAYS_TRUE
28052799
end
2806-
elseif isdefined_globalref(g)
2807-
nothrow = true
28082800
elseif InferenceParams(interp).assume_bindings_static
28092801
consistent = inaccessiblememonly = ALWAYS_TRUE
2810-
rt = Union{}
2802+
if isdefined_globalref(g)
2803+
nothrow = true
2804+
else
2805+
rt = Union{}
2806+
end
2807+
elseif isdefinedconst_globalref(g)
2808+
nothrow = true
28112809
end
28122810
return RTEffects(rt, nothrow ? Union{} : UndefVarError, Effects(EFFECTS_TOTAL; consistent, nothrow, inaccessiblememonly))
28132811
end
28142812

28152813
function handle_global_assignment!(interp::AbstractInterpreter, frame::InferenceState, lhs::GlobalRef, @nospecialize(newty))
28162814
effect_free = ALWAYS_FALSE
2817-
nothrow = global_assignment_nothrow(lhs.mod, lhs.name, newty)
2815+
nothrow = global_assignment_nothrow(lhs.mod, lhs.name, ignorelimited(newty))
28182816
inaccessiblememonly = ALWAYS_FALSE
28192817
if !nothrow
28202818
sub_curr_ssaflag!(frame, IR_FLAG_NOTHROW)
@@ -3019,7 +3017,6 @@ end
30193017
return BasicStmtChange(nothing, rt, exct)
30203018
end
30213019
changes = nothing
3022-
stmt = stmt::Expr
30233020
hd = stmt.head
30243021
if hd === :(=)
30253022
(; rt, exct) = abstract_eval_statement(interp, stmt.args[2], pc_vartable, frame)

0 commit comments

Comments
 (0)