Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more small changes for trimming #55255

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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