Skip to content

[6.1] Treat swift_willThrow(Typed) as not locking or performing allocation #77811

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

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Nov 22, 2024

  • Description: The @_noLocks/@_noAllocation checking considers throwing a typed error to always use generic metadata, even though it is designed not to unless specifically hooked (by a debugger). Teach the checker to allow typed errors in @_noLocks/@_noAllocation` mode.
  • Origination: With the introduction of typed throws, we failed to account for this checking pass.
  • Risk: Low.
  • Tested: New tests.
  • Main pull request: Treat swift_willThrow(Typed) as not locking or performing allocation #77780
  • Radar: rdar://140230684
  • Reviewed by: Erik Eckstein

Prior to throwing, Swift emits a call to `swift_willThrow(Typed)`,
which allows various diagnostic tools (such as debuggers and testing
libraries) to intercept errors at the point where they are initially
thrown.

Since `swift_willThrow(Typed)` can be hooked by arbitrary code at
runtime, there is no way for it to meet performance constraints like
@_noLocks or @_noAllocation. Therefore, in a function that has those
performance constraints specified, disable emission of the call to
`swift_willThrow(Typed)`.

Fixes rdar://140230684.

(cherry picked from commit eff9bac)
@DougGregor DougGregor requested a review from a team as a code owner November 22, 2024 18:23
@DougGregor
Copy link
Member Author

@swift-ci please test

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor DougGregor enabled auto-merge December 2, 2024 06:54
@DougGregor DougGregor merged commit 95f0252 into swiftlang:release/6.1 Dec 2, 2024
5 checks passed
@DougGregor DougGregor deleted the willthrow-no-locks-6.1 branch December 2, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants