@@ -1816,6 +1816,8 @@ struct TargetForeignTypeMetadata : public TargetMetadata<Runtime> {
1816
1816
using StoredSize = typename Runtime::StoredSize;
1817
1817
using InitializationFunction_t =
1818
1818
void (*)(TargetForeignTypeMetadata<Runtime> *selectedMetadata);
1819
+ using RuntimeMetadataPointer =
1820
+ ConstTargetMetadataPointer<Runtime, swift::TargetForeignTypeMetadata>;
1819
1821
1820
1822
// / Foreign type metadata may have extra header fields depending on
1821
1823
// / the flags.
@@ -1830,14 +1832,12 @@ struct TargetForeignTypeMetadata : public TargetMetadata<Runtime> {
1830
1832
// / The Swift-mangled name of the type. This is the uniquing key for the
1831
1833
// / type.
1832
1834
TargetPointer<Runtime, const char > Name;
1833
-
1835
+
1834
1836
// / A pointer to the actual, runtime-uniqued metadata for this
1835
1837
// / type. This is essentially an invasive cache for the lookup
1836
1838
// / structure.
1837
- mutable std::atomic<
1838
- ConstTargetMetadataPointer<Runtime, swift::TargetForeignTypeMetadata>
1839
- > Unique;
1840
-
1839
+ mutable std::atomic<RuntimeMetadataPointer> Unique;
1840
+
1841
1841
// / Various flags.
1842
1842
enum : StoredSize {
1843
1843
// / This metadata has an initialization callback function. If
@@ -1856,9 +1856,8 @@ struct TargetForeignTypeMetadata : public TargetMetadata<Runtime> {
1856
1856
return reinterpret_cast <TargetPointer<Runtime, const char >>(
1857
1857
asFullMetadata (this )->Name );
1858
1858
}
1859
-
1860
- ConstTargetMetadataPointer<Runtime, swift::TargetForeignTypeMetadata>
1861
- getCachedUniqueMetadata () const {
1859
+
1860
+ RuntimeMetadataPointer getCachedUniqueMetadata () const {
1862
1861
#if __alpha__
1863
1862
// TODO: This can be a relaxed-order load if there is no initialization
1864
1863
// function. On platforms we care about, consume is no more expensive than
@@ -1869,15 +1868,13 @@ struct TargetForeignTypeMetadata : public TargetMetadata<Runtime> {
1869
1868
#endif
1870
1869
return asFullMetadata (this )->Unique .load (SWIFT_MEMORY_ORDER_CONSUME);
1871
1870
}
1872
-
1873
- void
1874
- setCachedUniqueMetadata (
1875
- ConstTargetMetadataPointer<Runtime, swift::TargetForeignTypeMetadata> unique)
1876
- const {
1877
- assert ((asFullMetadata (this )->Unique == nullptr
1878
- || asFullMetadata (this )->Unique == unique)
1879
- && " already set unique metadata" );
1880
-
1871
+
1872
+ void setCachedUniqueMetadata (RuntimeMetadataPointer unique) const {
1873
+ assert ((static_cast <RuntimeMetadataPointer>(asFullMetadata (this )->Unique ) ==
1874
+ nullptr ||
1875
+ asFullMetadata (this )->Unique == unique) &&
1876
+ " already set unique metadata" );
1877
+
1881
1878
// If there is no initialization function, this can be a relaxed store.
1882
1879
if (!hasInitializationFunction ())
1883
1880
asFullMetadata (this )->Unique .store (unique, std::memory_order_relaxed);
0 commit comments