Skip to content

Commit

Permalink
Merge branch 'master' into styled-markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge authored Feb 11, 2024
2 parents 4d1ffb4 + c4bec9a commit bd47dc8
Show file tree
Hide file tree
Showing 94 changed files with 791 additions and 1,157 deletions.
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ endif
ifeq ($(OS), WINNT)
HAVE_SSP := 1
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(BUILDROOT)/src/julia.expmap \
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic -lole32
JLDFLAGS += -Wl,--stack,8388608
ifeq ($(ARCH),i686)
JLDFLAGS += -Wl,--large-address-aware
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Compiler/Runtime improvements
* A new `LazyLibrary` type is exported from `Libdl` for use in building chained lazy library
loads, primarily to be used within JLLs ([#50074]).
* Added support for annotating `Base.@assume_effects` on code blocks ([#52400]).
* The libuv library has been updated from a base of v1.44.2 to v1.48.0 ([#49937]).

Command-line option changes
---------------------------
Expand Down Expand Up @@ -86,6 +87,7 @@ New library functions
* `Sys.username()` can be used to return the current user's username ([#51897]).
* `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]).
* `IdSet` is now exported from Base and considered public ([#53262]).

New library features
--------------------
Expand Down
2 changes: 1 addition & 1 deletion base/abstractdict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ end
Update `d`, removing elements for which `f` is `false`.
The function `f` is passed `key=>value` pairs.
# Example
# Examples
```jldoctest
julia> d = Dict(1=>"a", 2=>"b", 3=>"c")
Dict{Int64, String} with 3 entries:
Expand Down
6 changes: 3 additions & 3 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,13 @@ eval(Core, quote
end)

function CodeInstance(
mi::MethodInstance, @nospecialize(rettype), @nospecialize(exctype), @nospecialize(inferred_const),
mi::MethodInstance, owner, @nospecialize(rettype), @nospecialize(exctype), @nospecialize(inferred_const),
@nospecialize(inferred), const_flags::Int32, min_world::UInt, max_world::UInt,
ipo_effects::UInt32, effects::UInt32, @nospecialize(analysis_results),
relocatability::UInt8)
return ccall(:jl_new_codeinst, Ref{CodeInstance},
(Any, Any, Any, Any, Any, Int32, UInt, UInt, UInt32, UInt32, Any, UInt8),
mi, rettype, exctype, inferred_const, inferred, const_flags, min_world, max_world,
(Any, Any, Any, Any, Any, Any, Int32, UInt, UInt, UInt32, UInt32, Any, UInt8),
mi, owner, rettype, exctype, inferred_const, inferred, const_flags, min_world, max_world,
ipo_effects, effects, analysis_results,
relocatability)
end
Expand Down
2 changes: 1 addition & 1 deletion base/cartesian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Generate a function call expression with keyword arguments `kw...`. As
in the case of [`@ncall`](@ref), `sym` represents any number of function arguments, the
last of which may be an anonymous-function expression and is expanded into `N` arguments.
# Example
# Examples
```jldoctest
julia> using Base.Cartesian
Expand Down
7 changes: 4 additions & 3 deletions base/cmd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
abstract type AbstractCmd end

# libuv process option flags
const UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = UInt8(1 << 2)
const UV_PROCESS_DETACHED = UInt8(1 << 3)
const UV_PROCESS_WINDOWS_HIDE = UInt8(1 << 4)
const UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = UInt32(1 << 2)
const UV_PROCESS_DETACHED = UInt32(1 << 3)
const UV_PROCESS_WINDOWS_HIDE = UInt32(1 << 4)
const UV_PROCESS_WINDOWS_DISABLE_EXACT_NAME = UInt32(1 << 7)

struct Cmd <: AbstractCmd
exec::Vector{String}
Expand Down
17 changes: 12 additions & 5 deletions base/compiler/cicache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ Internally, each `MethodInstance` keep a unique global cache of code instances
that have been created for the given method instance, stratified by world age
ranges. This struct abstracts over access to this cache.
"""
struct InternalCodeCache end
struct InternalCodeCache
owner::Any # `jl_egal` is used for comparison
end

function setindex!(cache::InternalCodeCache, ci::CodeInstance, mi::MethodInstance)
@assert ci.owner === cache.owner
ccall(:jl_mi_cache_insert, Cvoid, (Any, Any), mi, ci)
return cache
end

const GLOBAL_CI_CACHE = InternalCodeCache()

struct WorldRange
min_world::UInt
max_world::UInt
Expand Down Expand Up @@ -49,11 +50,11 @@ WorldView(wvc::WorldView, wr::WorldRange) = WorldView(wvc.cache, wr)
WorldView(wvc::WorldView, args...) = WorldView(wvc.cache, args...)

function haskey(wvc::WorldView{InternalCodeCache}, mi::MethodInstance)
return ccall(:jl_rettype_inferred, Any, (Any, UInt, UInt), mi, first(wvc.worlds), last(wvc.worlds)) !== nothing
return ccall(:jl_rettype_inferred, Any, (Any, Any, UInt, UInt), wvc.cache.owner, mi, first(wvc.worlds), last(wvc.worlds)) !== nothing
end

function get(wvc::WorldView{InternalCodeCache}, mi::MethodInstance, default)
r = ccall(:jl_rettype_inferred, Any, (Any, UInt, UInt), mi, first(wvc.worlds), last(wvc.worlds))
r = ccall(:jl_rettype_inferred, Any, (Any, Any, UInt, UInt), wvc.cache.owner, mi, first(wvc.worlds), last(wvc.worlds))
if r === nothing
return default
end
Expand All @@ -70,3 +71,9 @@ function setindex!(wvc::WorldView{InternalCodeCache}, ci::CodeInstance, mi::Meth
setindex!(wvc.cache, ci, mi)
return wvc
end

function code_cache(interp::AbstractInterpreter)
cache = InternalCodeCache(cache_owner(interp))
worlds = WorldRange(get_inference_world(interp))
return WorldView(cache, worlds)
end
2 changes: 1 addition & 1 deletion base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function CodeInstance(interp::AbstractInterpreter, result::InferenceResult,
end
end
# relocatability = isa(inferred_result, String) ? inferred_result[end] : UInt8(0)
return CodeInstance(result.linfo,
return CodeInstance(result.linfo, cache_owner(interp),
widenconst(result_type), widenconst(result.exc_result), rettype_const, inferred_result,
const_flags, first(valid_worlds), last(valid_worlds),
# TODO: Actually do something with non-IPO effects
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ the following methods to satisfy the `AbstractInterpreter` API requirement:
- `OptimizationParams(interp::NewInterpreter)` - return an `OptimizationParams` instance
- `get_inference_world(interp::NewInterpreter)` - return the world age for this interpreter
- `get_inference_cache(interp::NewInterpreter)` - return the local inference cache
- `code_cache(interp::NewInterpreter)` - return the global inference cache
- `cache_owner(interp::NewInterpreter)` - return the owner of any new cache entries
"""
:(AbstractInterpreter)

Expand Down Expand Up @@ -404,7 +404,7 @@ InferenceParams(interp::NativeInterpreter) = interp.inf_params
OptimizationParams(interp::NativeInterpreter) = interp.opt_params
get_inference_world(interp::NativeInterpreter) = interp.world
get_inference_cache(interp::NativeInterpreter) = interp.inf_cache
code_cache(interp::NativeInterpreter) = WorldView(GLOBAL_CI_CACHE, get_inference_world(interp))
cache_owner(interp::NativeInterpreter) = nothing

"""
already_inferred_quick_test(::AbstractInterpreter, ::MethodInstance)
Expand Down
19 changes: 0 additions & 19 deletions base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,25 +321,6 @@ function iterate(iter::BackedgeIterator, i::Int=1)
return BackedgePair(item, backedges[i+1]::MethodInstance), i+2 # `invoke` calls
end

"""
add_invalidation_callback!(callback, mi::MethodInstance)
Register `callback` to be triggered upon the invalidation of `mi`.
`callback` should a function taking two arguments, `callback(replaced::MethodInstance, max_world::UInt32)`,
and it will be recursively invoked on `MethodInstance`s within the invalidation graph.
"""
function add_invalidation_callback!(@nospecialize(callback), mi::MethodInstance)
if !isdefined(mi, :callbacks)
callbacks = mi.callbacks = Any[callback]
else
callbacks = mi.callbacks::Vector{Any}
if !any(@nospecialize(cb)->cb===callback, callbacks)
push!(callbacks, callback)
end
end
return callbacks
end

#########
# types #
#########
Expand Down
2 changes: 1 addition & 1 deletion base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ second is used for rounding the imaginary components.
which rounds to the nearest integer, with ties (fractional values of 0.5)
being rounded to the nearest even integer.
# Example
# Examples
```jldoctest
julia> round(3.14 + 4.5im)
3.0 + 4.0im
Expand Down
2 changes: 1 addition & 1 deletion base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ f(y) = [x for x in y]
standard ones) on type-inference. Use [`Base.@nospecializeinfer`](@ref) together with
`@nospecialize` to additionally suppress inference.
# Example
# Examples
```julia
julia> f(A::AbstractArray) = g(A)
Expand Down
2 changes: 1 addition & 1 deletion base/experimental.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ When issuing a hint, the output should typically start with `\\n`.
If you define custom exception types, your `showerror` method can
support hints by calling [`Experimental.show_error_hints`](@ref).
# Example
# Examples
```
julia> module Hinter
Expand Down
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export
Missing,
NTuple,
IdDict,
IdSet,
OrdinalRange,
Pair,
PartialQuickSort,
Expand Down
2 changes: 1 addition & 1 deletion base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ end
Tells the compiler to infer `f` using the declared types of `@nospecialize`d arguments.
This can be used to limit the number of compiler-generated specializations during inference.
# Example
# Examples
```julia
julia> f(A::AbstractArray) = g(A)
Expand Down
70 changes: 69 additions & 1 deletion base/filesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@

module Filesystem

"""
JL_O_APPEND
JL_O_ASYNC
JL_O_CLOEXEC
JL_O_CREAT
JL_O_DIRECT
JL_O_DIRECTORY
JL_O_DSYNC
JL_O_EXCL
JL_O_FSYNC
JL_O_LARGEFILE
JL_O_NDELAY
JL_O_NOATIME
JL_O_NOCTTY
JL_O_NOFOLLOW
JL_O_NONBLOCK
JL_O_PATH
JL_O_RANDOM
JL_O_RDONLY
JL_O_RDWR
JL_O_RSYNC
JL_O_SEQUENTIAL
JL_O_SHORT_LIVED
JL_O_SYNC
JL_O_TEMPORARY
JL_O_TMPFILE
JL_O_TRUNC
JL_O_WRONLY
Enum constant for the `open` syscall, where `JL_O_*` corresponds to the `O_*` constant.
See [the libuv docs](https://docs.libuv.org/en/v1.x/fs.html#file-open-constants) for more details.
"""
(:JL_O_APPEND, :JL_O_ASYNC, :JL_O_CLOEXEC, :JL_O_CREAT, :JL_O_DIRECT,
:JL_O_DIRECTORY, :JL_O_DSYNC, :JL_O_EXCL, :JL_O_FSYNC, :JL_O_LARGEFILE,
:JL_O_NOATIME, :JL_O_NOCTTY, :JL_O_NDELAY, :JL_O_NOFOLLOW, :JL_O_NONBLOCK,
:JL_O_PATH, :JL_O_RANDOM, :JL_O_RDONLY, :JL_O_RDWR, :JL_O_RSYNC,
:JL_O_SEQUENTIAL, :JL_O_SHORT_LIVED, :JL_O_SYNC, :JL_O_TEMPORARY,
:JL_O_TMPFILE, :JL_O_TRUNC, :JL_O_WRONLY)

const S_IFDIR = 0o040000 # directory
const S_IFCHR = 0o020000 # character device
const S_IFBLK = 0o060000 # block device
Expand Down Expand Up @@ -31,6 +70,36 @@ const S_IWOTH = 0o0002 # write by other
const S_IXOTH = 0o0001 # execute by other
const S_IRWXO = 0o0007 # mask for other permissions

"""
S_IRUSR
S_IWUSR
S_IXUSR
S_IRGRP
S_IWGRP
S_IXGRP
S_IROTH
S_IWOTH
S_IXOTH
Constants for file access permission bits.
The general structure is `S_I[permission][class]`
where `permission` is `R` for read, `W` for write, and `X` for execute,
and `class` is `USR` for user/owner, `GRP` for group, and `OTH` for other.
"""
(:S_IRUSR, :S_IWUSR, :S_IXUSR, :S_IRGRP, :S_IWGRP, :S_IXGRP, :S_IROTH, :S_IWOTH, :S_IXOTH)

"""
S_IRWXU
S_IRWXG
S_IRWXO
Constants for file access permission masks, i.e. the combination of read, write,
and execute permissions for a class.
The general structure is `S_IRWX[class]`
where `class` is `U` for user/owner, `G` for group, and `O` for other.
"""
(:S_IRWXU, :S_IRWXG, :S_IRWXO)

export File,
StatStruct,
# open,
Expand All @@ -48,7 +117,6 @@ export File,
JL_O_SEQUENTIAL,
JL_O_RANDOM,
JL_O_NOCTTY,
JL_O_NOCTTY,
JL_O_NONBLOCK,
JL_O_NDELAY,
JL_O_SYNC,
Expand Down
1 change: 0 additions & 1 deletion base/gcutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ end
A finalizer may be registered at object construction. In the following example note that
we implicitly rely on the finalizer returning the newly created mutable struct `x`.
# Example
```julia
mutable struct MyMutableStruct
bar
Expand Down
9 changes: 5 additions & 4 deletions base/iddict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
IdDict([itr])
`IdDict{K,V}()` constructs a hash table using [`objectid`](@ref) as hash and
`===` as equality with keys of type `K` and values of type `V`.
`===` as equality with keys of type `K` and values of type `V`. See [`Dict`](@ref)
for further help and [`IdSet`](@ref) for the set version of this.
See [`Dict`](@ref) for further help. In the example below, The `Dict`
keys are all `isequal` and therefore get hashed the same, so they get overwritten.
The `IdDict` hashes by object-id, and thus preserves the 3 different keys.
In the example below, the `Dict` keys are all `isequal` and therefore get hashed
the same, so they get overwritten. The `IdDict` hashes by object-id, and thus
preserves the 3 different keys.
# Examples
```julia-repl
Expand Down
23 changes: 23 additions & 0 deletions base/idset.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

"""
IdSet{T}([itr])
IdSet()
IdSet{T}() constructs a set (see [`Set`](@ref)) using
`===` as equality with values of type `V`.
In the example below, the values are all `isequal` so they get overwritten.
The `IdSet` compares by `===` so preserves the 3 different keys.
Examples
≡≡≡≡≡≡≡≡
julia> Set(Any[true, 1, 1.0])
Set{Any} with 1 element:
1.0
julia> IdSet{Any}(Any[true, 1, 1.0])
IdSet{Any} with 3 elements:
1.0
1
true
"""
mutable struct IdSet{K} <: AbstractSet{K}
list::Memory{Any}
idxs::Union{Memory{UInt8}, Memory{UInt16}, Memory{UInt32}}
Expand Down
2 changes: 1 addition & 1 deletion base/indices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ julia> extrema(b)
Return a `LinearIndices` array with the specified shape or [`axes`](@ref).
# Example
# Examples
The main purpose of this constructor is intuitive conversion
from cartesian to linear indexing:
Expand Down
4 changes: 2 additions & 2 deletions base/libdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ end
Wrapper for usage with `do` blocks to automatically close the dynamic library once
control flow leaves the `do` block scope.
# Example
# Examples
```julia
vendor = dlopen("libblas") do lib
if Libdl.dlsym(lib, :openblas_set_num_threads; throw_error=false) !== nothing
Expand Down Expand Up @@ -234,7 +234,7 @@ end
Get the full path of the library `libname`.
# Example
# Examples
```julia-repl
julia> dlpath("libjulia")
```
Expand Down
Loading

0 comments on commit bd47dc8

Please sign in to comment.