Skip to content

Commit 51e5afe

Browse files
authored
Backports for Julia 1.12-rc2 (#59006)
2 parents 228edd6 + 3960ef4 commit 51e5afe

File tree

18 files changed

+268
-16
lines changed

18 files changed

+268
-16
lines changed

Compiler/src/tfuncs.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ function add_tfunc(@nospecialize(f::Builtin), minarg::Int, maxarg::Int, @nospeci
8888
end
8989

9090
add_tfunc(throw, 1, 1, @nospecs((𝕃::AbstractLattice, x)->Bottom), 0)
91-
add_tfunc(Core.throw_methoderror, 1, INT_INF, @nospecs((𝕃::AbstractLattice, x)->Bottom), 0)
91+
92+
# FIXME: the inlining cost for this built-in should be 0 (just like throw), but it is set to
93+
# 1000 to avoid regressions associated with the Compiler inlining too eagerly, especially when
94+
# encounting `if @generated` expressions.
95+
#
96+
# c.f. https://github.com/JuliaLang/julia/issues/58915#issuecomment-3070231392
97+
add_tfunc(Core.throw_methoderror, 1, INT_INF, @nospecs((𝕃::AbstractLattice, x)->Bottom), 1000)
9298

9399
# the inverse of typeof_tfunc
94100
# returns (type, isexact, isconcrete, istype)

Compiler/test/inline.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,3 +2310,32 @@ g_noinline_invoke(x) = f_noinline_invoke(x)
23102310
let src = code_typed1(g_noinline_invoke, (Union{Symbol,Nothing},))
23112311
@test !any(@nospecialize(x)->isa(x,GlobalRef), src.code)
23122312
end
2313+
2314+
# https://github.com/JuliaLang/julia/issues/58915
2315+
f58915(nt) = @inline Base.setindex(nt, 2, :next)
2316+
# This function should fully-inline, i.e. it should have only built-in / intrinsic calls
2317+
# and no invokes or dynamic calls of user code
2318+
let src = code_typed(f58915, Tuple{@NamedTuple{next::UInt32,prev::UInt32}})[1].first
2319+
# Any calls should be built-in calls
2320+
@test count(iscall(f->!isa(singleton_type(argextype(f, src)), Core.Builtin)), src.code) == 0
2321+
# There should be no invoke at all
2322+
@test count(isinvoke(Returns(true)), src.code) == 0
2323+
end
2324+
2325+
# https://github.com/JuliaLang/julia/issues/58915#issuecomment-3061421895
2326+
let src = code_typed(Base.setindex, (@NamedTuple{next::UInt32,prev::UInt32}, Int, Symbol))[1].first
2327+
@test count(isinvoke(:merge_fallback), src.code) == 0
2328+
@test count(iscall((src, Base.merge_fallback)), src.code) == 0
2329+
end
2330+
2331+
# https://github.com/JuliaLang/julia/pull/58996#issuecomment-3073496955
2332+
f58996(::Int) = :int
2333+
f58996(::String) = :string
2334+
call_f58996(x) = f58996(x)
2335+
callcall_f58996(x) = call_f58996(x);
2336+
let src = code_typed(callcall_f58996, (Any,))[1].first
2337+
# Any calls should be built-in calls
2338+
@test_broken count(iscall(f->!isa(singleton_type(argextype(f, src)), Core.Builtin)), src.code) == 0
2339+
# There should be no invoke at all
2340+
@test count(isinvoke(Returns(true)), src.code) == 0
2341+
end

base/precompilation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ function _precompilepkgs(pkgs::Vector{String},
920920
flags, cacheflags = config
921921
task = @async begin
922922
try
923-
loaded = haskey(Base.loaded_modules, pkg)
923+
loaded = warn_loaded && haskey(Base.loaded_modules, pkg)
924924
for dep in deps # wait for deps to finish
925925
wait(was_processed[(dep,config)])
926926
end
@@ -983,7 +983,7 @@ function _precompilepkgs(pkgs::Vector{String},
983983
delete!(std_outputs, pkg_config) # so it's not shown as warnings, given error report
984984
failed_deps[pkg_config] = (strict || is_project_dep) ? string(sprint(showerror, err), "\n", strip(errmsg)) : ""
985985
!fancyprint && @lock print_lock begin
986-
println(io, " "^9, color_string("", Base.error_color()), name)
986+
println(io, " "^12, color_string("", Base.error_color()), name)
987987
end
988988
else
989989
rethrow()

base/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function _isself(ft::DataType)
3535
name = ftname.singletonname
3636
ftname.name === name && return false
3737
mod = parentmodule(ft)
38-
return invokelatest(isdefinedglobal, mod, name) && ft === typeof(invokelatest(getglobal, mod, name))
38+
return isdefinedglobal(mod, name) && ft === typeof(getglobal(mod, name))
3939
end
4040

4141
function show(io::IO, ::MIME"text/plain", f::Function)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b6596d36c153d476101b1db14c5d1400
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1bc6f3f3d8a40f4ce51928115e44a46b89a2a1404f0ad9fa0b8cdca4641ab42eab3ff0d9a6a2cbbb57dbaf7effcf399b188716b3fc2d18b32f750d5fb363669f

deps/checksums/Pkg-e7a2dfecbfe43cf1c32f1ccd1e98a4dca52726ee.tar.gz/md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps/checksums/Pkg-e7a2dfecbfe43cf1c32f1ccd1e98a4dca52726ee.tar.gz/sha512

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ Manual = [
166166
"manual/code-loading.md",
167167
"manual/profile.md",
168168
"manual/stacktraces.md",
169+
"manual/memory-management.md",
169170
"manual/performance-tips.md",
170171
"manual/workflow-tips.md",
171172
"manual/style-guide.md",

doc/src/manual/command-line-interface.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ The following is a complete list of command-line switches available when launchi
179179
|`-m`, `--module <Package> [args]` |Run entry point of `Package` (`@main` function) with `args'|
180180
|`-L`, `--load <file>` |Load `<file>` immediately on all processors|
181181
|`-t`, `--threads {auto\|N[,auto\|M]}` |Enable N[+M] threads; N threads are assigned to the `default` threadpool, and if M is specified, M threads are assigned to the `interactive` threadpool; `auto` tries to infer a useful default number of threads to use but the exact behavior might change in the future. Currently sets N to the number of CPUs assigned to this Julia process based on the OS-specific affinity assignment interface if supported (Linux and Windows) or to the number of CPU threads if not supported (MacOS) or if process affinity is not configured, and sets M to 1.|
182-
| `--gcthreads=N[,M]` |Use N threads for the mark phase of GC and M (0 or 1) threads for the concurrent sweeping phase of GC. N is set to the number of compute threads and M is set to 0 if unspecified.|
182+
| `--gcthreads=N[,M]` |Use N threads for the mark phase of GC and M (0 or 1) threads for the concurrent sweeping phase of GC. N is set to the number of compute threads and M is set to 0 if unspecified. See [Memory Management and Garbage Collection](@ref man-memory-management) for more details.|
183183
|`-p`, `--procs {N\|auto}` |Integer value N launches N additional local worker processes; `auto` launches as many workers as the number of local CPU threads (logical cores)|
184184
|`--machine-file <file>` |Run processes on hosts listed in `<file>`|
185185
|`-i`, `--interactive` |Interactive mode; REPL runs and `isinteractive()` is true|
@@ -205,7 +205,7 @@ The following is a complete list of command-line switches available when launchi
205205
|`--track-allocation=@<path>` |Count bytes but only in files that fall under the given file path/directory. The `@` prefix is required to select this option. A `@` with no path will track the current directory.|
206206
|`--task-metrics={yes\|no*}` |Enable the collection of per-task metrics|
207207
|`--bug-report=KIND` |Launch a bug report session. It can be used to start a REPL, run a script, or evaluate expressions. It first tries to use BugReporting.jl installed in current environment and falls back to the latest compatible BugReporting.jl if not. For more information, see `--bug-report=help`.|
208-
|`--heap-size-hint=<size>` |Forces garbage collection if memory usage is higher than the given value. The value may be specified as a number of bytes, optionally in units of KB, MB, GB, or TB, or as a percentage of physical memory with %.|
208+
|`--heap-size-hint=<size>` |Forces garbage collection if memory usage is higher than the given value. The value may be specified as a number of bytes, optionally in units of KB, MB, GB, or TB, or as a percentage of physical memory with %. See [Memory Management and Garbage Collection](@ref man-memory-management) for more details.|
209209
|`--compile={yes*\|no\|all\|min}` |Enable or disable JIT compiler, or request exhaustive or minimal compilation|
210210
|`--output-o <name>` |Generate an object file (including system image data)|
211211
|`--output-ji <name>` |Generate a system image data file (.ji)|

0 commit comments

Comments
 (0)