Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into jfang/heap-snapshot…
Browse files Browse the repository at this point in the history
…-stream-dev
  • Loading branch information
JianFangAtRai committed Jan 30, 2024
2 parents 4525fea + 3510f4e commit 1a06f9c
Show file tree
Hide file tree
Showing 263 changed files with 3,997 additions and 1,836 deletions.
31 changes: 24 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ New language features
API. Symbols marked with `export` are now also treated as public API. The
difference between `public` and `export` is that `public` names do not become
available when `using` a package/module ([#50105]).
* `ScopedValue` implement dynamic scope with inheritance across tasks ([#50958]).
* `ScopedValue` implements dynamic scope with inheritance across tasks ([#50958]).
* The new macro `Base.Cartesian.@ncallkw` is analogous to `Base.Cartesian.@ncall`,
but allows to add keyword arguments to the function call ([#51501]).
* Support for Unicode 15.1 ([#51799]).
Expand All @@ -30,7 +30,7 @@ Language changes
wants to begin exiting.
* Code coverage and malloc tracking is no longer generated during the package precompilation stage.
Further, during these modes pkgimage caches are now used for packages that are not being tracked.
Meaning that coverage testing (the default for `julia-actions/julia-runtest`) will by default use
This means that coverage testing (the default for `julia-actions/julia-runtest`) will by default use
pkgimage caches for all other packages than the package being tested, likely meaning faster test
execution. ([#52123])

Expand All @@ -42,7 +42,7 @@ Compiler/Runtime improvements
* Updated GC heuristics to count allocated pages instead of individual objects ([#50144]).
* A new `LazyLibrary` type is exported from `Libdl` for use in building chained lazy library
loads, primarily to be used within JLLs ([#50074]).
* Added a support for annotating `Base.@assume_effects` on code block ([#52400]).
* Added support for annotating `Base.@assume_effects` on code blocks ([#52400]).

Command-line option changes
---------------------------
Expand All @@ -68,12 +68,11 @@ New library functions

* `in!(x, s::AbstractSet)` will return whether `x` is in `s`, and insert `x` in `s` if not.
* The new `Libc.mkfifo` function wraps the `mkfifo` C function on Unix platforms ([#34587]).
* `hardlink(src, dst)` can be used to create hard links ([#41639]).
* `diskstat(path=pwd())` can be used to return statistics about the disk ([#42248]).
* `copyuntil(out, io, delim)` and `copyline(out, io)` copy data into an `out::IO` stream ([#48273]).
* `eachrsplit(string, pattern)` iterates split substrings right to left.
* `Sys.username()` can be used to return the current user's username ([#51897]).
* `wrap(Array, m::Union{MemoryRef{T}, Memory{T}}, dims)` which is the safe counterpart to `unsafe_wrap` ([#52049]).
* `wrap(Array, m::Union{MemoryRef{T}, Memory{T}}, dims)` is the safe counterpart to `unsafe_wrap` ([#52049]).
* `GC.logging_enabled()` can be used to test whether GC logging has been enabled via `GC.enable_logging` ([#51647]).

New library features
--------------------
Expand All @@ -93,6 +92,7 @@ New library features
content is fully written, then call `closewrite` manually to avoid
data-races. Or use the callback form of `open` to have all that handled
automatically.
* `@timed` now additionally returns the elapsed compilation and recompilation time ([#52889])

Standard library changes
------------------------
Expand All @@ -108,6 +108,12 @@ Standard library changes
* The new `@styled_str` string macro provides a convenient way of creating a
`AnnotatedString` with various faces or other attributes applied ([#49586]).

#### JuliaSyntaxHighlighting

* A new standard library for applying syntax highlighting to Julia code, this
uses `JuliaSyntax` and `StyledStrings` to implement a `highlight` function
that creates an `AnnotatedString` with syntax highlighting applied.

#### Package Manager

#### LinearAlgebra
Expand Down Expand Up @@ -139,7 +145,14 @@ Standard library changes
#### REPL

* Tab complete hints now show in lighter text while typing in the repl. To disable
set `Base.active_repl.options.hint_tab_completes = false` ([#51229]).
set `Base.active_repl.options.hint_tab_completes = false` interactively, or in startup.jl:
```
if VERSION >= v"1.11.0-0"
atreplinit() do repl
repl.options.hint_tab_completes = false
end
end
``` ([#51229]).
* Meta-M with an empty prompt now toggles the contextual module between the previous non-Main
contextual module and Main so that switching back and forth is simple. ([#51616], [#52670])
Expand All @@ -152,6 +165,8 @@ Standard library changes
#### Dates
The undocumented function `adjust` is no longer exported but is now documented
#### Statistics
* Statistics is now an upgradeable standard library ([#46501]).
Expand All @@ -171,6 +186,8 @@ Standard library changes
Deprecated or removed
---------------------
* `Base.map`, `Iterators.map`, and `foreach` lost their single-argument methods ([#52631]).
External dependencies
---------------------
Expand Down
1 change: 1 addition & 0 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ function __init__()
init_load_path()
init_active_project()
append!(empty!(_sysimage_modules), keys(loaded_modules))
empty!(explicit_loaded_modules)
if haskey(ENV, "JULIA_MAX_NUM_PRECOMPILE_FILES")
MAX_NUM_PRECOMPILE_FILES[] = parse(Int, ENV["JULIA_MAX_NUM_PRECOMPILE_FILES"])
end
Expand Down
12 changes: 9 additions & 3 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,24 @@ $(build_bindir)/7z$(EXE):
rm -f "$@" && \
ln -svf "$(7Z_PATH)" "$@"

symlink_lld: $(build_bindir)/lld$(EXE)
symlink_llvm_utils: $(build_depsbindir)/lld$(EXE) $(build_depsbindir)/dsymutil$(EXE)

ifneq ($(USE_SYSTEM_LLD),0)
SYMLINK_SYSTEM_LIBRARIES += symlink_lld
SYMLINK_SYSTEM_LIBRARIES += symlink_llvm_utils
LLD_PATH := $(shell which lld$(EXE))
DSYMUTIL_PATH := $(shell which dsymutil$(EXE))
endif

$(build_bindir)/lld$(EXE):
$(build_depsbindir)/lld$(EXE):
[ -e "$(LLD_PATH)" ] && \
rm -f "$@" && \
ln -svf "$(LLD_PATH)" "$@"

$(build_depsbindir)/dsymutil$(EXE):
[ -e "$(DSYMUTIL_PATH)" ] && \
rm -f "$@" && \
ln -svf "$(DSYMUTIL_PATH)" "$@"

# the following excludes: libuv.a, libutf8proc.a

ifneq ($(USE_SYSTEM_LIBM),0)
Expand Down
22 changes: 10 additions & 12 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,20 @@ end
has_offset_axes(A, B, ...)
Return `true` if the indices of `A` start with something other than 1 along any axis.
If multiple arguments are passed, equivalent to `has_offset_axes(A) | has_offset_axes(B) | ...`.
If multiple arguments are passed, equivalent to `has_offset_axes(A) || has_offset_axes(B) || ...`.
See also [`require_one_based_indexing`](@ref).
"""
has_offset_axes() = false
has_offset_axes(A) = _any_tuple(x->Int(first(x))::Int != 1, false, axes(A)...)
has_offset_axes(A::AbstractVector) = Int(firstindex(A))::Int != 1 # improve performance of a common case (ranges)
# Use `_any_tuple` to avoid unneeded invoke.
# note: this could call `any` directly if the compiler can infer it
has_offset_axes(As...) = _any_tuple(has_offset_axes, false, As...)
has_offset_axes(::Colon) = false
has_offset_axes(::Array) = false
# note: this could call `any` directly if the compiler can infer it. We don't use _any_tuple
# here because it stops full elision in some cases (#49332) and we don't need handling of
# `missing` (has_offset_axes(A) always returns a Bool)
has_offset_axes(A, As...) = has_offset_axes(A) || has_offset_axes(As...)


"""
require_one_based_indexing(A::AbstractArray)
Expand Down Expand Up @@ -881,7 +884,7 @@ julia> empty([1.0, 2.0, 3.0], String)
String[]
```
"""
empty(a::AbstractVector{T}, ::Type{U}=T) where {T,U} = Vector{U}()
empty(a::AbstractVector{T}, ::Type{U}=T) where {T,U} = similar(a, U, 0)

# like empty, but should return a mutable collection, a Vector by default
emptymutable(a::AbstractVector{T}, ::Type{U}=T) where {T,U} = Vector{U}()
Expand Down Expand Up @@ -3108,9 +3111,8 @@ julia> foreach((x, y) -> println(x, " with ", y), tri, 'a':'z')
7 with c
```
"""
foreach(f) = (f(); nothing)
foreach(f, itr) = (for x in itr; f(x); end; nothing)
foreach(f, itrs...) = (for z in zip(itrs...); f(z...); end; nothing)
foreach(f, itr, itrs...) = (for z in zip(itr, itrs...); f(z...); end; nothing)

## map over arrays ##

Expand Down Expand Up @@ -3282,10 +3284,6 @@ end
concatenate_setindex!(R, v, I...) = (R[I...] .= (v,); R)
concatenate_setindex!(R, X::AbstractArray, I...) = (R[I...] = X)

## 0 arguments

map(f) = f()

## 1 argument

function map!(f::F, dest::AbstractArray, A::AbstractArray) where F
Expand Down Expand Up @@ -3421,7 +3419,7 @@ julia> map(+, [1 2; 3 4], [1,10,100,1000], zeros(3,1)) # iterates until 3rd is
102.0
```
"""
map(f, iters...) = collect(Generator(f, iters...))
map(f, it, iters...) = collect(Generator(f, it, iters...))

# multi-item push!, pushfirst! (built on top of type-specific 1-item version)
# (note: must not cause a dispatch loop when 1-item case is not defined)
Expand Down
23 changes: 20 additions & 3 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ See also [`copy!`](@ref Base.copy!), [`copyto!`](@ref), [`deepcopy`](@ref).
copy

@eval function copy(a::Array{T}) where {T}
# `jl_genericmemory_copy_slice` only throws when the size exceeds the max allocation
# size, but since we're copying an existing array, we're guaranteed that this will not happen.
@_nothrow_meta
ref = a.ref
newmem = ccall(:jl_genericmemory_copy_slice, Ref{Memory{T}}, (Any, Ptr{Cvoid}, Int), ref.mem, ref.ptr_or_offset, length(a))
return $(Expr(:new, :(typeof(a)), :(Core.memoryref(newmem)), :(a.size)))
Expand Down Expand Up @@ -1040,6 +1043,7 @@ end
array_new_memory(mem::Memory, newlen::Int) = typeof(mem)(undef, newlen) # when implemented, this should attempt to first expand mem

function _growbeg!(a::Vector, delta::Integer)
@_noub_meta
delta = Int(delta)
delta == 0 && return # avoid attempting to index off the end
delta >= 0 || throw(ArgumentError("grow requires delta >= 0"))
Expand Down Expand Up @@ -1077,6 +1081,7 @@ function _growbeg!(a::Vector, delta::Integer)
end

function _growend!(a::Vector, delta::Integer)
@_noub_meta
delta = Int(delta)
delta >= 0 || throw(ArgumentError("grow requires delta >= 0"))
ref = a.ref
Expand Down Expand Up @@ -1113,6 +1118,7 @@ function _growend!(a::Vector, delta::Integer)
end

function _growat!(a::Vector, i::Integer, delta::Integer)
@_terminates_globally_noub_meta
delta = Int(delta)
i = Int(i)
i == 1 && return _growbeg!(a, delta)
Expand Down Expand Up @@ -1715,10 +1721,11 @@ julia> insert!(Any[1:6;], 3, "here")
```
"""
function insert!(a::Array{T,1}, i::Integer, item) where T
@_noub_meta
# Throw convert error before changing the shape of the array
_item = item isa T ? item : convert(T, item)::T
_growat!(a, i, 1)
# _growat! already did bound check
# :noub, because _growat! already did bound check
@inbounds a[i] = _item
return a
end
Expand Down Expand Up @@ -2294,7 +2301,9 @@ findfirst(A::AbstractArray) = findnext(A, first(keys(A)))
findnext(predicate::Function, A, i)
Find the next index after or including `i` of an element of `A`
for which `predicate` returns `true`, or `nothing` if not found.
for which `predicate` returns `true`, or `nothing` if not found. This works for
Arrays, Strings, and most other collections that support [`getindex`](@ref),
[`keys(A)`](@ref), and [`nextind`](@ref).
Indices are of the same type as those returned by [`keys(A)`](@ref)
and [`pairs(A)`](@ref).
Expand All @@ -2312,6 +2321,9 @@ julia> A = [1 4; 2 2];
julia> findnext(isodd, A, CartesianIndex(1, 1))
CartesianIndex(1, 1)
julia> findnext(isspace, "a b c", 3)
4
```
"""
function findnext(testf::Function, A, start)
Expand Down Expand Up @@ -2468,7 +2480,9 @@ findlast(A::AbstractArray) = findprev(A, last(keys(A)))
findprev(predicate::Function, A, i)
Find the previous index before or including `i` of an element of `A`
for which `predicate` returns `true`, or `nothing` if not found.
for which `predicate` returns `true`, or `nothing` if not found. This works for
Arrays, Strings, and most other collections that support [`getindex`](@ref),
[`keys(A)`](@ref), and [`nextind`](@ref).
Indices are of the same type as those returned by [`keys(A)`](@ref)
and [`pairs(A)`](@ref).
Expand All @@ -2494,6 +2508,9 @@ julia> A = [4 6; 1 2]
julia> findprev(isodd, A, CartesianIndex(1, 2))
CartesianIndex(2, 1)
julia> findprev(isspace, "a b c", 3)
2
```
"""
function findprev(testf::Function, A, start)
Expand Down
Loading

0 comments on commit 1a06f9c

Please sign in to comment.