Skip to content

Commit 19165be

Browse files
authored
more small changes for trimming (#55255)
A few more unobjectionable, NFC changes from #55047.
2 parents 0ef8a91 + b0c2281 commit 19165be

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

base/strings/io.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ end
246246

247247
# optimized methods to avoid iterating over chars
248248
write(io::IO, s::Union{String,SubString{String}}) =
249-
GC.@preserve s Int(unsafe_write(io, pointer(s), reinterpret(UInt, sizeof(s))))::Int
249+
GC.@preserve s (unsafe_write(io, pointer(s), reinterpret(UInt, sizeof(s))) % Int)::Int
250250
print(io::IO, s::Union{String,SubString{String}}) = (write(io, s); nothing)
251251

252252
"""

base/sysinfo.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ end
165165
# without pulling in anything unnecessary like `CPU_NAME`
166166
function __init_build()
167167
global BINDIR = ccall(:jl_get_julia_bindir, Any, ())::String
168-
vers = "v$(VERSION.major).$(VERSION.minor)"
168+
vers = "v$(string(VERSION.major)).$(string(VERSION.minor))"
169169
global STDLIB = abspath(BINDIR, "..", "share", "julia", "stdlib", vers)
170170
nothing
171171
end

base/task.jl

+12-9
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,14 @@ macro sync_add(expr)
813813
end
814814
end
815815

816+
throwto_repl_task(@nospecialize val) = throwto(getfield(active_repl_backend, :backend_task)::Task, val)
817+
818+
function is_repl_running()
819+
return isdefined(Base, :active_repl_backend) &&
820+
(getfield(active_repl_backend, :backend_task)::Task)._state === task_state_runnable &&
821+
getfield(active_repl_backend, :in_eval)
822+
end
823+
816824
# runtime system hook called when a task finishes
817825
function task_done_hook(t::Task)
818826
# `finish_task` sets `sigatomic` before entering this function
@@ -834,10 +842,8 @@ function task_done_hook(t::Task)
834842
end
835843

836844
if err && !handled && Threads.threadid() == 1
837-
if isa(result, InterruptException) && active_repl_backend !== nothing &&
838-
active_repl_backend.backend_task._state === task_state_runnable && isempty(Workqueue) &&
839-
active_repl_backend.in_eval
840-
throwto(active_repl_backend.backend_task, result) # this terminates the task
845+
if isa(result, InterruptException) && isempty(Workqueue) && is_repl_running()
846+
throwto_repl_task(result)
841847
end
842848
end
843849
# Clear sigatomic before waiting
@@ -848,11 +854,8 @@ function task_done_hook(t::Task)
848854
# If an InterruptException happens while blocked in the event loop, try handing
849855
# the exception to the REPL task since the current task is done.
850856
# issue #19467
851-
if Threads.threadid() == 1 &&
852-
isa(e, InterruptException) && active_repl_backend !== nothing &&
853-
active_repl_backend.backend_task._state === task_state_runnable && isempty(Workqueue) &&
854-
active_repl_backend.in_eval
855-
throwto(active_repl_backend.backend_task, e)
857+
if Threads.threadid() == 1 && isa(e, InterruptException) && isempty(Workqueue) && is_repl_running()
858+
throwto_repl_task(e)
856859
else
857860
rethrow()
858861
end

0 commit comments

Comments
 (0)