Skip to content

Commit

Permalink
more small changes for trimming (#55255)
Browse files Browse the repository at this point in the history
A few more unobjectionable, NFC changes from #55047.
  • Loading branch information
JeffBezanson committed Aug 1, 2024
2 parents 0ef8a91 + b0c2281 commit 19165be
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

"""
Expand Down
2 changes: 1 addition & 1 deletion base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 12 additions & 9 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 19165be

Please sign in to comment.