Skip to content

Commit

Permalink
Also nospecialize unwrap_exception.
Browse files Browse the repository at this point in the history
Unclear why this was left out from
#6...

There's still probably more improvement to be made here, but I ran into
test failures on julia master, so we're leaving that as a separate
change in #14.
  • Loading branch information
NHDaly committed Jun 6, 2023
1 parent 397314d commit 023da5a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ExceptionUnwrapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ struct UnwrappedExceptionNotFound{RequestedType, ExceptionType} <: Base.Exceptio
end
UnwrappedExceptionNotFound{R}(e::E) where {R,E} = UnwrappedExceptionNotFound{R,E}(e)

# We have confirmed via Cthulhu and the Allocations profiler that these seem to correctly
# not be specializing, and not allocating.
@nospecialize

# Base case is that e -> e
unwrap_exception(e) = e
Expand All @@ -115,10 +118,6 @@ unwrap_exception(e::Base.CapturedException) = e.ex

has_wrapped_exception(::T, ::Type{T}) where T = true

# We have confirmed via Cthulhu and the Allocations profiler that these seem to correctly
# not be specializing, and not allocating.
@nospecialize

# Types don't match, do the unrolling, but prevent inference since this happens at runtime
# and only during exception catch blocks, and might have arbitrarily nested types. And in
# practice, we've seen julia's inference really struggles here.
Expand Down

0 comments on commit 023da5a

Please sign in to comment.