Skip to content

Conversation

@mikeash
Copy link
Contributor

@mikeash mikeash commented Nov 20, 2025

Replace C++ implementation of swift_beginAccess and swift_endAccess with (almost) pure Swift implementation. Helpers remain in C++ for TLS, getting return addresses, and raising a fatal error on violations.

This change also moves the exclusivity access set head from the shared SwiftTLSContext structure to a dedicated TLS key. This improves performance, which is important for exclusivity checking. This is particularly the case where we can inline TLS access with a constant key, as on Darwin ARM64.

The code that bridges exclusivity tracking into Concurrency remains in C++. The new Swift implementation exposes a few helpers for it to use as a replacement for directly manipulating the C++ implementation. I'd like to move this code into Swift as well, but one thing at a time.

rdar://161122309

@mikeash mikeash force-pushed the exclusivity-go-swifter branch from 6bfccef to ca054a8 Compare November 20, 2025 18:34
Replace C++ implementation of swift_beginAccess and swift_endAccess with (almost) pure Swift implementation. Helpers remain in C++ for TLS, getting return addresses, and raising a fatal error on violations.

This change also moves the exclusivity access set head from the shared SwiftTLSContext structure to a dedicated TLS key. This improves performance, which is important for exclusivity checking. This is particularly the case where we can inline TLS access with a constant key, as on Darwin ARM64.

The code that bridges exclusivity tracking into Concurrency remains in C++. The new Swift implementation exposes a few helpers for it to use as a replacement for directly manipulating the C++ implementation.

rdar://161122309
@mikeash mikeash force-pushed the exclusivity-go-swifter branch from ca054a8 to 5a326f9 Compare November 20, 2025 19:53
@mikeash mikeash marked this pull request as ready for review November 20, 2025 22:06
@mikeash
Copy link
Contributor Author

mikeash commented Nov 20, 2025

@swift-ci please test

@@ -0,0 +1,262 @@
import SwiftShims
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file not have the copyright header?

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