Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Jan 9, 2025

This PR removes the C++ section discovery logic that's used to look up Swift's type metadata sections. Instead, we reuse the new logic used for test content sections (written in Swift.)

I did not attempt to translate to Swift the logic to extract Swift types from Swift's metadata records. This logic relies pretty heavily on precise C++ data structure layouts and uses pointer authentication as well as relative pointers. Swift does not guarantee the same structure layout as C++, nor does it provide API for pointer authentication, nor do value types in Swift have stable addresses that can be used to compute addresses from relative offsets.

Resolves #764.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR removes the C++ _section_ discovery logic that's used to look up Swift's
type metadata sections. Instead, we reuse the new logic used for test content
sections (written in Swift.)
@grynspan grynspan added the enhancement New feature or request label Jan 9, 2025
@grynspan grynspan added this to the Swift 6.x milestone Jan 9, 2025
@grynspan grynspan self-assigned this Jan 9, 2025
@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test


#include <algorithm>
#include <array>
#include <atomic>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can probably strip down these includes now, but will leave that for another PR.

@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test Windows

@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Jan 9, 2025

@swift-ci test Windows

@grynspan
Copy link
Contributor Author

@swift-ci test

Co-authored-by: Stuart Montgomery <smontgomery@apple.com>
@grynspan grynspan requested a review from stmontgomery January 10, 2025 20:21
@grynspan grynspan merged commit 52aa355 into main Jan 10, 2025
@grynspan grynspan deleted the jgrynspan/remove-cxx-discovery branch January 10, 2025 21:19
@grynspan grynspan added the less-c++ 🐀 Work to reduce the size of our C++ codebase and/or dependencies label Jan 19, 2025
@grynspan grynspan added the discovery 🔎 test content discovery label Mar 12, 2025
@grynspan grynspan added the tech-debt 💾 reduces technical debt label Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discovery 🔎 test content discovery enhancement New feature or request less-c++ 🐀 Work to reduce the size of our C++ codebase and/or dependencies tech-debt 💾 reduces technical debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translate Discovery.cpp to Swift

3 participants