Skip to content

Commit

Permalink
Merge branch 'master' into gb/parallel-stack-pools
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaraldi authored Sep 6, 2024
2 parents aef2ba0 + 6f04ee0 commit 015cf96
Show file tree
Hide file tree
Showing 62 changed files with 1,535 additions and 814 deletions.
15 changes: 4 additions & 11 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1095,20 +1095,13 @@ LIBUNWIND:=
else ifneq ($(DISABLE_LIBUNWIND), 0)
LIBUNWIND:=
else
ifeq ($(USE_SYSTEM_LIBUNWIND), 1)
ifneq ($(OS),Darwin)
LIBUNWIND:=-lunwind
# Only for linux since we want to use not yet released libunwind features
JCFLAGS+=-DSYSTEM_LIBUNWIND
JCPPFLAGS+=-DSYSTEM_LIBUNWIND
endif
else
ifneq ($(findstring $(OS),Darwin OpenBSD),)
LIBUNWIND:=-lunwind
JCPPFLAGS+=-DLLVMLIBUNWIND
else
LIBUNWIND:=-lunwind
endif
else ifeq ($(USE_SYSTEM_LIBUNWIND), 1)
# Only for linux and freebsd since we want to use not yet released gnu libunwind features
JCFLAGS+=-DSYSTEM_LIBUNWIND
JCPPFLAGS+=-DSYSTEM_LIBUNWIND
endif
endif

Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ Standard library changes
* `Profile.take_heap_snapshot` takes a new keyword argument, `redact_data::Bool`,
that is `true` by default. When set, the contents of Julia objects are not emitted
in the heap snapshot. This currently only applies to strings. ([#55326])
* `Profile.print()` now colors Base/Core/Package modules similarly to how they are in stacktraces.
Also paths, even if truncated, are now clickable in terminals that support URI links
to take you to the specified `JULIA_EDITOR` for the given file & line number. ([#55335])

#### Random

Expand Down
4 changes: 2 additions & 2 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ function exec_options(opts)
invokelatest(show, Core.eval(Main, parse_input_line(arg)))
println()
elseif cmd == 'm'
@eval Main import $(Symbol(arg)).main
entrypoint = push!(split(arg, "."), "main")
Base.eval(Main, Expr(:import, Expr(:., Symbol.(entrypoint)...)))
if !should_use_main_entrypoint()
error("`main` in `$arg` not declared as entry point (use `@main` to do so)")
end
return false

elseif cmd == 'L'
# load file immediately on all processors
if !distributed_mode
Expand Down
66 changes: 41 additions & 25 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
arginfo::ArgInfo, si::StmtInfo, @nospecialize(atype),
sv::AbsIntState, max_methods::Int)
𝕃ₚ, 𝕃ᵢ = ipo_lattice(interp), typeinf_lattice(interp)
ₚ, ₚ, = partialorder(𝕃ₚ), join(𝕃ₚ), join(𝕃ᵢ)
ₚ, ₚ, ₚ, = partialorder(𝕃ₚ), strictneqpartialorder(𝕃ₚ), join(𝕃ₚ), join(𝕃ᵢ)
argtypes = arginfo.argtypes
matches = find_method_matches(interp, argtypes, atype; max_methods)
if isa(matches, FailedMethodMatch)
Expand Down Expand Up @@ -97,9 +97,8 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
else
add_remark!(interp, sv, "[constprop] Discarded because the result was wider than inference")
end
if !(exct ₚ const_call_result.exct)
exct = const_call_result.exct
(; const_result, edge) = const_call_result
if const_call_result.exct exct
(; exct, const_result, edge) = const_call_result
else
add_remark!(interp, sv, "[constprop] Discarded exception type because result was wider than inference")
end
Expand Down Expand Up @@ -154,7 +153,7 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
end
# Treat the exception type separately. Currently, constprop often cannot determine the exception type
# because consistent-cy does not apply to exceptions.
if !(this_exct const_call_result.exct)
if const_call_result.exct this_exct
this_exct = const_call_result.exct
(; const_result, edge) = const_call_result
else
Expand Down Expand Up @@ -2135,12 +2134,13 @@ function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::Stmt
(types, isexact, isconcrete, istype) = instanceof_tfunc(argtype_by_index(argtypes, 3), false)
isexact || return CallMeta(Any, Any, Effects(), NoCallInfo())
unwrapped = unwrap_unionall(types)
if types === Bottom || !(unwrapped isa DataType) || unwrapped.name !== Tuple.name
return CallMeta(Bottom, Any, EFFECTS_THROWS, NoCallInfo())
types === Bottom && return CallMeta(Bottom, Any, EFFECTS_THROWS, NoCallInfo())
if !(unwrapped isa DataType && unwrapped.name === Tuple.name)
return CallMeta(Bottom, TypeError, EFFECTS_THROWS, NoCallInfo())
end
argtype = argtypes_to_type(argtype_tail(argtypes, 4))
nargtype = typeintersect(types, argtype)
nargtype === Bottom && return CallMeta(Bottom, Any, EFFECTS_THROWS, NoCallInfo())
nargtype === Bottom && return CallMeta(Bottom, TypeError, EFFECTS_THROWS, NoCallInfo())
nargtype isa DataType || return CallMeta(Any, Any, Effects(), NoCallInfo()) # other cases are not implemented below
isdispatchelem(ft) || return CallMeta(Any, Any, Effects(), NoCallInfo()) # check that we might not have a subtype of `ft` at runtime, before doing supertype lookup below
ft = ft::DataType
Expand All @@ -2154,7 +2154,7 @@ function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::Stmt
tienv = ccall(:jl_type_intersection_with_env, Any, (Any, Any), nargtype, method.sig)::SimpleVector
ti = tienv[1]; env = tienv[2]::SimpleVector
result = abstract_call_method(interp, method, ti, env, false, si, sv)
(; rt, edge, effects, volatile_inf_result) = result
(; rt, exct, edge, effects, volatile_inf_result) = result
match = MethodMatch(ti, env, method, argtype <: method.sig)
res = nothing
sig = match.spec_types
Expand All @@ -2168,20 +2168,28 @@ function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::Stmt
# argtypes′[i] = t ⊑ a ? t : a
# end
𝕃ₚ = ipo_lattice(interp)
, , = partialorder(𝕃ₚ), strictneqpartialorder(𝕃ₚ), join(𝕃ₚ)
f = singleton_type(ft′)
invokecall = InvokeCall(types, lookupsig)
const_call_result = abstract_call_method_with_const_args(interp,
result, f, arginfo, si, match, sv, invokecall)
const_result = volatile_inf_result
if const_call_result !== nothing
if (𝕃ₚ, const_call_result.rt, rt)
if const_call_result.rt rt
(; rt, effects, const_result, edge) = const_call_result
end
if const_call_result.exct exct
(; exct, const_result, edge) = const_call_result
end
end
rt = from_interprocedural!(interp, rt, sv, arginfo, sig)
info = InvokeCallInfo(match, const_result)
edge !== nothing && add_invoke_backedge!(sv, lookupsig, edge)
return CallMeta(rt, Any, effects, info)
if !match.fully_covers
effects = Effects(effects; nothrow=false)
exct = exct TypeError
end
return CallMeta(rt, exct, effects, info)
end

function invoke_rewrite(xs::Vector{Any})
Expand All @@ -2202,16 +2210,16 @@ end

function abstract_throw(interp::AbstractInterpreter, argtypes::Vector{Any}, ::AbsIntState)
na = length(argtypes)
𝕃ᵢ = typeinf_lattice(interp)
= join(typeinf_lattice(interp))
if na == 2
argtype2 = argtypes[2]
if isvarargtype(argtype2)
exct = tmerge(𝕃ᵢ, unwrapva(argtype2), ArgumentError)
exct = unwrapva(argtype2) ArgumentError
else
exct = argtype2
end
elseif na == 3 && isvarargtype(argtypes[3])
exct = tmerge(𝕃ᵢ, argtypes[2], ArgumentError)
exct = argtypes[2] ArgumentError
else
exct = ArgumentError
end
Expand Down Expand Up @@ -2334,35 +2342,43 @@ end
function abstract_call_opaque_closure(interp::AbstractInterpreter,
closure::PartialOpaque, arginfo::ArgInfo, si::StmtInfo, sv::AbsIntState, check::Bool=true)
sig = argtypes_to_type(arginfo.argtypes)
result = abstract_call_method(interp, closure.source::Method, sig, Core.svec(), false, si, sv)
(; rt, edge, effects, volatile_inf_result) = result
tt = closure.typ
sigT = (unwrap_unionall(tt)::DataType).parameters[1]
match = MethodMatch(sig, Core.svec(), closure.source, sig <: rewrap_unionall(sigT, tt))
ocargsig = rewrap_unionall((unwrap_unionall(tt)::DataType).parameters[1], tt)
ocargsig′ = unwrap_unionall(ocargsig)
ocargsig′ isa DataType || return CallMeta(Any, Any, Effects(), NoCallInfo())
ocsig = rewrap_unionall(Tuple{Tuple, ocargsig′.parameters...}, ocargsig)
hasintersect(sig, ocsig) || return CallMeta(Union{}, Union{MethodError,TypeError}, EFFECTS_THROWS, NoCallInfo())
ocmethod = closure.source::Method
result = abstract_call_method(interp, ocmethod, sig, Core.svec(), false, si, sv)
(; rt, exct, edge, effects, volatile_inf_result) = result
match = MethodMatch(sig, Core.svec(), ocmethod, sig <: ocsig)
𝕃ₚ = ipo_lattice(interp)
= (𝕃ₚ)
, , = partialorder(𝕃ₚ), strictneqpartialorder(𝕃ₚ), join(𝕃ₚ)
const_result = volatile_inf_result
if !result.edgecycle
const_call_result = abstract_call_method_with_const_args(interp, result,
nothing, arginfo, si, match, sv)
if const_call_result !== nothing
if const_call_result.rt rt
if const_call_result.rt rt
(; rt, effects, const_result, edge) = const_call_result
end
if const_call_result.exct exct
(; exct, const_result, edge) = const_call_result
end
end
end
if check # analyze implicit type asserts on argument and return type
ftt = closure.typ
(aty, rty) = (unwrap_unionall(ftt)::DataType).parameters
rty = rewrap_unionall(rty isa TypeVar ? rty.lb : rty, ftt)
if !(rt ₚ rty && tuple_tfunc(𝕃ₚ, arginfo.argtypes[2:end]) rewrap_unionall(aty, ftt))
rty = (unwrap_unionall(tt)::DataType).parameters[2]
rty = rewrap_unionall(rty isa TypeVar ? rty.ub : rty, tt)
if !(rt rty && sig ocsig)
effects = Effects(effects; nothrow=false)
exct = exct TypeError
end
end
rt = from_interprocedural!(interp, rt, sv, arginfo, match.spec_types)
info = OpaqueClosureCallInfo(match, const_result)
edge !== nothing && add_backedge!(sv, edge)
return CallMeta(rt, Any, effects, info)
return CallMeta(rt, exct, effects, info)
end

function most_general_argtypes(closure::PartialOpaque)
Expand Down
5 changes: 3 additions & 2 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
end
end
if ccall(:jl_get_module_infer, Cint, (Any,), method.module) == 0 && !generating_output(#=incremental=#false)
add_remark!(interp, caller, "Inference is disabled for the target module")
add_remark!(interp, caller, "[typeinf_edge] Inference is disabled for the target module")
return EdgeCallResult(Any, Any, nothing, Effects())
end
if !is_cached(caller) && frame_parent(caller) === nothing
Expand Down Expand Up @@ -897,7 +897,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
end
frame = InferenceState(result, cache_mode, interp) # always use the cache for edge targets
if frame === nothing
add_remark!(interp, caller, "Failed to retrieve source")
add_remark!(interp, caller, "[typeinf_edge] Failed to retrieve source")
# can't get the source for this, so we know nothing
if cache_mode == CACHE_MODE_GLOBAL
engine_reject(interp, ci)
Expand All @@ -918,6 +918,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
return EdgeCallResult(frame.bestguess, exc_bestguess, edge, effects, volatile_inf_result)
elseif frame === true
# unresolvable cycle
add_remark!(interp, caller, "[typeinf_edge] Unresolvable cycle")
return EdgeCallResult(Any, Any, nothing, Effects())
end
# return the current knowledge about this cycle
Expand Down
34 changes: 29 additions & 5 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ of the file or directory `src` refers to.
Return `dst`.
!!! note
The `cp` function is different from the `cp` command. The `cp` function always operates on
The `cp` function is different from the `cp` Unix command. The `cp` function always operates on
the assumption that `dst` is a file, while the command does different things depending
on whether `dst` is a directory or a file.
Using `force=true` when `dst` is a directory will result in loss of all the contents present
Expand Down Expand Up @@ -438,6 +438,16 @@ julia> mv("hello.txt", "goodbye.txt", force=true)
julia> rm("goodbye.txt");
```
!!! note
The `mv` function is different from the `mv` Unix command. The `mv` function by
default will error if `dst` exists, while the command will delete
an existing `dst` file by default.
Also the `mv` function always operates on
the assumption that `dst` is a file, while the command does different things depending
on whether `dst` is a directory or a file.
Using `force=true` when `dst` is a directory will result in loss of all the contents present
in the `dst` directory, and `dst` will become a file that has the contents of `src` instead.
"""
function mv(src::AbstractString, dst::AbstractString; force::Bool=false)
if force
Expand Down Expand Up @@ -1183,16 +1193,30 @@ function unlink(p::AbstractString)
end

"""
rename(oldpath::AbstractString, newpath::AbstractString)
Base.rename(oldpath::AbstractString, newpath::AbstractString)
Change the name of a file from `oldpath` to `newpath`. If `newpath` is an existing file it may be replaced.
Equivalent to [rename(2)](https://man7.org/linux/man-pages/man2/rename.2.html).
Throws an `IOError` on failure.
Change the name of a file or directory from `oldpath` to `newpath`.
If `newpath` is an existing file or empty directory it may be replaced.
Equivalent to [rename(2)](https://man7.org/linux/man-pages/man2/rename.2.html) on Unix.
If a path contains a "\\0" throw an `ArgumentError`.
On other failures throw an `IOError`.
Return `newpath`.
This is a lower level filesystem operation used to implement [`mv`](@ref).
OS-specific restrictions may apply when `oldpath` and `newpath` are in different directories.
Currently there are a few differences in behavior on Windows which may be resolved in a future release.
Specifically, currently on Windows:
1. `rename` will fail if `oldpath` or `newpath` are opened files.
2. `rename` will fail if `newpath` is an existing directory.
3. `rename` may work if `newpath` is a file and `oldpath` is a directory.
4. `rename` may remove `oldpath` if it is a hardlink to `newpath`.
See also: [`mv`](@ref).
!!! compat "Julia 1.12"
This method was made public in Julia 1.12.
"""
function rename(oldpath::AbstractString, newpath::AbstractString)
err = ccall(:jl_fs_rename, Int32, (Cstring, Cstring), oldpath, newpath)
Expand Down
6 changes: 5 additions & 1 deletion base/precompilation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,12 @@ function precompilepkgs(pkgs::Vector{String}=String[];
seconds_elapsed = round(Int, (time_ns() - time_start) / 1e9)
ndeps = count(values(was_recompiled))
if ndeps > 0 || !isempty(failed_deps) || (quick_exit && !isempty(std_outputs))
str = sprint() do iostr
str = sprint(context=io) do iostr
if !quick_exit
if fancyprint # replace the progress bar
what = isempty(requested_pkgs) ? "packages finished." : "$(join(requested_pkgs, ", ", " and ")) finished."
printpkgstyle(iostr, :Precompiling, what)
end
plural = length(configs) > 1 ? "dependency configurations" : ndeps == 1 ? "dependency" : "dependencies"
print(iostr, " $(ndeps) $(plural) successfully precompiled in $(seconds_elapsed) seconds")
if n_already_precomp > 0 || !isempty(circular_deps)
Expand Down
3 changes: 3 additions & 0 deletions base/public.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public
reseteof,
link_pipe!,

# filesystem operations
rename,

# misc
notnothing,
runtests,
Expand Down
2 changes: 1 addition & 1 deletion base/strings/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ end
i = i′
@inbounds l = codeunit(s, i)
(l < 0x80) | (0xf8 l) && return i+1
@assert l >= 0xc0
@assert l >= 0xc0 "invalid codeunit"
end
# first continuation byte
(i += 1) > n && return i
Expand Down
2 changes: 2 additions & 0 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ global STDLIB::String = "$BINDIR/../share/julia/stdlib/v$(VERSION.major).$(VERSI
# In case STDLIB change after julia is built, the variable below can be used
# to update cached method locations to updated ones.
const BUILD_STDLIB_PATH = STDLIB
# Similarly, this is the root of the julia repo directory that julia was built from
const BUILD_ROOT_PATH = "$BINDIR/../.."

# helper to avoid triggering precompile warnings

Expand Down
4 changes: 1 addition & 3 deletions contrib/julia-config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ function ldlibs(doframework)
"julia"
end
if Sys.isunix()
return "-Wl,-rpath,$(shell_escape(libDir())) " *
(Sys.isapple() ? string() : "-Wl,-rpath,$(shell_escape(private_libDir())) ") *
"-l$libname"
return "-Wl,-rpath,$(shell_escape(libDir())) -Wl,-rpath,$(shell_escape(private_libDir())) -l$libname"
else
return "-l$libname -lopenlibm"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
791c9ca37077fdc36b959a17904dd935
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
96520326931685d4300e825a302010f113e942aaa55aa4ff12caf3e9df314309df993c97753ae482c2198db67678423885bf5ea40c743c8e4b6ef96d7b8d4472

This file was deleted.

This file was deleted.

Loading

0 comments on commit 015cf96

Please sign in to comment.