Commit Graph

4 Commits

Author SHA1 Message Date
Mike Ash
5bde0c98d8 [Runtime] Use Runtime types for size/stride in TargetValueWitnessTypes.
We want to use Runtime::StoredSize so the layout is correct when using an external Runtime template. size_t is correct in-process but may not be correct out of process.
2024-08-13 15:04:21 -04:00
Mike Ash
29c350e813 [Runtime] Create an external generic metadata builder.
Create a version of the metadata specialization code which is abstracted so that it can work in different contexts, such as building specialized metadata from dylibs on disk rather than from inside a running process.

The GenericMetadataBuilder class is templatized on a ReaderWriter. The ReaderWriter abstracts out everything that's different between in-process and external construction of this data. Instead of reading and writing pointers directly, the builder calls the ReaderWriter to resolve and write pointers. The ReaderWriter also handles symbol lookups and looking up other Swift types by name.

This is accompanied by a simple implementation of the ReaderWriter which works in-process. The abstracted calls to resolve and write pointers are implemented using standard pointer dereferencing.

A new SWIFT_DEBUG_VALIDATE_EXTERNAL_GENERIC_METADATA_BUILDER environment variable uses the in-process ReaderWriter to validate the builder by running it in parallel with the existing metadata builder code in the runtime. When enabled, the GenericMetadataBuilder is used to build a second copy of metadata built by the runtime, and the two are compared to ensure that they match. When this environment variable is not set, the new builder code is inactive.

The builder is incomplete, and this initial version only works on structs. Any unsupported type produces an error, and skips the validation.

rdar://116592420
2024-01-11 09:15:02 -05:00
John McCall
78de2fba7d [NFC] Move generic contexts and metadata references into separate headers 2022-03-23 02:18:39 -04:00
John McCall
e2332a34bc [NFC] Move ValueWitnessTable layout into its own file
I've also target-ified EnumValueWitnessTable while I was at it.
2022-03-22 21:58:27 -04:00