Commit Graph

3 Commits

Author SHA1 Message Date
Jonathan Grynspan
0664c3f333 Add a distinct hook for swift_willThrowTypedImpl(). (#71651)
Add a distinct hook for `swift_willThrowTypedImpl()`.

This PR adds a hook for `swift_willThrowTypedImpl()` that is distinct from
`swift_willThrow()`. The current implementation of `swift_willThrowTypedImpl()` creates a
temporary existential box for the thrown error and calls the `_swift_willThrow` hook that
is set by XCTest and swift-testing. Unfortunately, this temporary existential box isn't
very useful because its address is not expected to be stable.

Instead, expose a separate hook, `_swift_willThrowTypedImpl`, whose signature matches
that of the new ABI function. This hook can then be used by XCTest and swift-testing to
distinguish between typed throws and untyped throws and avoids creating a temporary
existential box when it won't be useful.

As implemented, if `_swift_willThrowTypedImpl` is not set but `_swift_willThrow` is, the
`swift_willThrowTypedImpl()` will fall back to calling `_swift_willThrow` with a temporary
existential box. We might decide this is unnecessary, but I figured it would allow us more
time to stage adoption of the new hook in the testing libraries.

Resolves rdar://122824443.
2024-02-16 17:30:44 -05:00
Jonathan Grynspan
e057172b6f Make _swift_willThrow atomic (#62349)
* Make _swift_willThrow atomic
2022-12-03 10:41:56 -05:00
Mike Ash
b8f5e841e2 [Runtime] Add a function pointer for intercepting swift_willThrow calls.
rdar://problem/53400364
2019-10-24 14:06:14 -04:00