From 920c936f86ee41d3c17b403cc8d6e947c6fbc93d Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 5 Jul 2024 14:01:43 -0400 Subject: [PATCH 1/3] avoid unnecessary inexact check in `write(::IO, ::String)` --- base/strings/io.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/strings/io.jl b/base/strings/io.jl index 46353ff6f7c29..aa2bc8afa170f 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -246,7 +246,7 @@ end # optimized methods to avoid iterating over chars write(io::IO, s::Union{String,SubString{String}}) = - GC.@preserve s Int(unsafe_write(io, pointer(s), reinterpret(UInt, sizeof(s))))::Int + GC.@preserve s (unsafe_write(io, pointer(s), reinterpret(UInt, sizeof(s))) % Int)::Int print(io::IO, s::Union{String,SubString{String}}) = (write(io, s); nothing) """ From ecf08ce3fa1d540dc774601249bf8ef52bfc6d43 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 25 Jul 2024 16:19:05 -0400 Subject: [PATCH 2/3] improve task_done_hook code for trimming --- base/task.jl | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/base/task.jl b/base/task.jl index 4f7b1ea979a94..ae99a71585c85 100644 --- a/base/task.jl +++ b/base/task.jl @@ -813,6 +813,14 @@ macro sync_add(expr) end end +throwto_repl_task(@nospecialize val) = throwto(getfield(active_repl_backend, :backend_task)::Task, val) + +function is_repl_running() + return isdefined(Base, :active_repl_backend) && + (getfield(active_repl_backend, :backend_task)::Task)._state === task_state_runnable && + getfield(active_repl_backend, :in_eval) +end + # runtime system hook called when a task finishes function task_done_hook(t::Task) # `finish_task` sets `sigatomic` before entering this function @@ -834,10 +842,8 @@ function task_done_hook(t::Task) end if err && !handled && Threads.threadid() == 1 - if isa(result, InterruptException) && active_repl_backend !== nothing && - active_repl_backend.backend_task._state === task_state_runnable && isempty(Workqueue) && - active_repl_backend.in_eval - throwto(active_repl_backend.backend_task, result) # this terminates the task + if isa(result, InterruptException) && isempty(Workqueue) && is_repl_running() + throwto_repl_task(result) end end # Clear sigatomic before waiting @@ -848,11 +854,8 @@ function task_done_hook(t::Task) # If an InterruptException happens while blocked in the event loop, try handing # the exception to the REPL task since the current task is done. # issue #19467 - if Threads.threadid() == 1 && - isa(e, InterruptException) && active_repl_backend !== nothing && - active_repl_backend.backend_task._state === task_state_runnable && isempty(Workqueue) && - active_repl_backend.in_eval - throwto(active_repl_backend.backend_task, e) + if Threads.threadid() == 1 && isa(e, InterruptException) && isempty(Workqueue) && is_repl_running() + throwto_repl_task(e) else rethrow() end From b0c22817ca42f28d535e3c1c957946eb2bd207e4 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 25 Jul 2024 16:28:24 -0400 Subject: [PATCH 3/3] make `Sysinfo.__init__` easier to compile --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 3cb95396502a9..d0dcac8c6d416 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -165,7 +165,7 @@ end # without pulling in anything unnecessary like `CPU_NAME` function __init_build() global BINDIR = ccall(:jl_get_julia_bindir, Any, ())::String - vers = "v$(VERSION.major).$(VERSION.minor)" + vers = "v$(string(VERSION.major)).$(string(VERSION.minor))" global STDLIB = abspath(BINDIR, "..", "share", "julia", "stdlib", vers) nothing end