Skip to content

Commit da2a066

Browse files
committed
Merge remote-tracking branch 'upstream/main' into implementation-only-symbol-visibility-fix
2 parents 3ca701e + 5a87482 commit da2a066

File tree

461 files changed

+12585
-6549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

461 files changed

+12585
-6549
lines changed

docs/ABI/Mangling.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ Globals
175175

176176
global ::= global 'MJ' // noncanonical specialized generic type metadata instantiation cache associated with global
177177
global ::= global 'MN' // noncanonical specialized generic type metadata for global
178+
global ::= global 'Mz' // canonical specialized generic type metadata caching token
178179

179180
#if SWIFT_RUNTIME_VERSION >= 5.4
180181
global ::= context (decl-name '_')+ 'WZ' // global variable one-time initialization function
@@ -218,6 +219,8 @@ types where the metadata itself has unknown layout.)
218219
global ::= global 'Tm' // merged function
219220
global ::= entity // some identifiable thing
220221
global ::= from-type to-type generic-signature? 'TR' // reabstraction thunk
222+
global ::= from-type to-type generic-signature? 'TR' // reabstraction thunk
223+
global ::= impl-function-type 'Tz' // objc-to-swift-async completion handler block implementation
221224
global ::= from-type to-type self-type generic-signature? 'Ty' // reabstraction thunk with dynamic 'Self' capture
222225
global ::= from-type to-type generic-signature? 'Tr' // obsolete mangling for reabstraction thunk
223226
global ::= entity generic-signature? type type* 'TK' // key path getter

include/swift/ABI/Metadata.h

Lines changed: 96 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -30,6 +30,7 @@
3030
#include "llvm/ADT/ArrayRef.h"
3131
#include "swift/Strings.h"
3232
#include "swift/Runtime/Config.h"
33+
#include "swift/Runtime/Once.h"
3334
#include "swift/ABI/MetadataValues.h"
3435
#include "swift/ABI/System.h"
3536
#include "swift/ABI/TrailingObjects.h"
@@ -2295,28 +2296,37 @@ struct TargetTypeMetadataRecord {
22952296
union {
22962297
/// A direct reference to a nominal type descriptor.
22972298
RelativeDirectPointerIntPair<TargetContextDescriptor<Runtime>,
2298-
TypeMetadataRecordKind>
2299+
TypeReferenceKind>
22992300
DirectNominalTypeDescriptor;
23002301

23012302
/// An indirect reference to a nominal type descriptor.
23022303
RelativeDirectPointerIntPair<TargetSignedPointer<Runtime, TargetContextDescriptor<Runtime> * __ptrauth_swift_type_descriptor>,
2303-
TypeMetadataRecordKind>
2304+
TypeReferenceKind>
23042305
IndirectNominalTypeDescriptor;
2306+
2307+
// We only allow a subset of the TypeReferenceKinds here.
2308+
// Should we just acknowledge that this is a different enum?
23052309
};
23062310

23072311
public:
2308-
TypeMetadataRecordKind getTypeKind() const {
2312+
TypeReferenceKind getTypeKind() const {
23092313
return DirectNominalTypeDescriptor.getInt();
23102314
}
23112315

23122316
const TargetContextDescriptor<Runtime> *
23132317
getContextDescriptor() const {
23142318
switch (getTypeKind()) {
2315-
case TypeMetadataRecordKind::DirectTypeDescriptor:
2319+
case TypeReferenceKind::DirectTypeDescriptor:
23162320
return DirectNominalTypeDescriptor.getPointer();
23172321

2318-
case TypeMetadataRecordKind::IndirectTypeDescriptor:
2322+
case TypeReferenceKind::IndirectTypeDescriptor:
23192323
return *IndirectNominalTypeDescriptor.getPointer();
2324+
2325+
// These types (and any others we might add to TypeReferenceKind
2326+
// in the future) are just never used in these lists.
2327+
case TypeReferenceKind::DirectObjCClassName:
2328+
case TypeReferenceKind::IndirectObjCClass:
2329+
return nullptr;
23202330
}
23212331

23222332
return nullptr;
@@ -2406,9 +2416,6 @@ struct TargetTypeReference {
24062416
/// A direct reference to an Objective-C class name.
24072417
RelativeDirectPointer<const char>
24082418
DirectObjCClassName;
2409-
2410-
/// A "reference" to some metadata kind, e.g. tuple.
2411-
MetadataKind MetadataKind;
24122419
};
24132420

24142421
const TargetContextDescriptor<Runtime> *
@@ -2422,18 +2429,12 @@ struct TargetTypeReference {
24222429

24232430
case TypeReferenceKind::DirectObjCClassName:
24242431
case TypeReferenceKind::IndirectObjCClass:
2425-
case TypeReferenceKind::MetadataKind:
24262432
return nullptr;
24272433
}
24282434

24292435
return nullptr;
24302436
}
24312437

2432-
enum MetadataKind getMetadataKind(TypeReferenceKind kind) const {
2433-
assert(kind == TypeReferenceKind::MetadataKind);
2434-
return MetadataKind;
2435-
}
2436-
24372438
#if SWIFT_OBJC_INTEROP
24382439
/// If this type reference is one of the kinds that supports ObjC
24392440
/// references,
@@ -2519,10 +2520,6 @@ struct TargetProtocolConformanceDescriptor final
25192520
return Flags.getTypeReferenceKind();
25202521
}
25212522

2522-
enum MetadataKind getMetadataKind() const {
2523-
return TypeRef.getMetadataKind(getTypeKind());
2524-
}
2525-
25262523
const char *getDirectObjCClassName() const {
25272524
return TypeRef.getDirectObjCClassName(getTypeKind());
25282525
}
@@ -2550,11 +2547,6 @@ struct TargetProtocolConformanceDescriptor final
25502547
TargetRelativeContextPointer<Runtime>>();
25512548
}
25522549

2553-
/// Whether this conformance is builtin by the compiler + runtime.
2554-
bool isBuiltin() const {
2555-
return getTypeKind() == TypeReferenceKind::MetadataKind;
2556-
}
2557-
25582550
/// Whether this conformance is non-unique because it has been synthesized
25592551
/// for a foreign type.
25602552
bool isSynthesizedNonUnique() const {
@@ -3796,6 +3788,11 @@ struct TargetCanonicalSpecializedMetadataAccessorsListEntry {
37963788
TargetRelativeDirectPointer<Runtime, MetadataResponse(MetadataRequest), /*Nullable*/ false> accessor;
37973789
};
37983790

3791+
template <typename Runtime>
3792+
struct TargetCanonicalSpecializedMetadatasCachingOnceToken {
3793+
TargetRelativeDirectPointer<Runtime, swift_once_t, /*Nullable*/ false> token;
3794+
};
3795+
37993796
template <typename Runtime>
38003797
class TargetTypeContextDescriptor
38013798
: public TargetContextDescriptor<Runtime> {
@@ -3882,7 +3879,9 @@ class TargetTypeContextDescriptor
38823879
}
38833880

38843881
const llvm::ArrayRef<TargetRelativeDirectPointer<Runtime, TargetMetadata<Runtime>, /*Nullable*/ false>>
3885-
getCanonicicalMetadataPrespecializations() const;
3882+
getCanonicicalMetadataPrespecializations() const;
3883+
3884+
swift_once_t *getCanonicalMetadataPrespecializationCachingOnceToken() const;
38863885

38873886
static bool classof(const TargetContextDescriptor<Runtime> *cd) {
38883887
return cd->getKind() >= ContextDescriptorKind::Type_First
@@ -4024,7 +4023,8 @@ class TargetClassDescriptor final
40244023
TargetObjCResilientClassStubInfo<Runtime>,
40254024
TargetCanonicalSpecializedMetadatasListCount<Runtime>,
40264025
TargetCanonicalSpecializedMetadatasListEntry<Runtime>,
4027-
TargetCanonicalSpecializedMetadataAccessorsListEntry<Runtime>> {
4026+
TargetCanonicalSpecializedMetadataAccessorsListEntry<Runtime>,
4027+
TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>> {
40284028
private:
40294029
using TrailingGenericContextObjects =
40304030
swift::TrailingGenericContextObjects<TargetClassDescriptor<Runtime>,
@@ -4039,7 +4039,8 @@ class TargetClassDescriptor final
40394039
TargetObjCResilientClassStubInfo<Runtime>,
40404040
TargetCanonicalSpecializedMetadatasListCount<Runtime>,
40414041
TargetCanonicalSpecializedMetadatasListEntry<Runtime>,
4042-
TargetCanonicalSpecializedMetadataAccessorsListEntry<Runtime>>;
4042+
TargetCanonicalSpecializedMetadataAccessorsListEntry<Runtime>,
4043+
TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>>;
40434044

40444045
using TrailingObjects =
40454046
typename TrailingGenericContextObjects::TrailingObjects;
@@ -4067,6 +4068,8 @@ class TargetClassDescriptor final
40674068
TargetRelativeDirectPointer<Runtime, MetadataResponse(MetadataRequest), /*Nullable*/ false>;
40684069
using MetadataAccessorListEntry =
40694070
TargetCanonicalSpecializedMetadataAccessorsListEntry<Runtime>;
4071+
using MetadataCachingOnceToken =
4072+
TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>;
40704073

40714074
using StoredPointer = typename Runtime::StoredPointer;
40724075
using StoredPointerDifference = typename Runtime::StoredPointerDifference;
@@ -4204,6 +4207,10 @@ class TargetClassDescriptor final
42044207
: 0;
42054208
}
42064209

4210+
size_t numTrailingObjects(OverloadToken<MetadataCachingOnceToken>) const {
4211+
return this->hasCanonicicalMetadataPrespecializations() ? 1 : 0;
4212+
}
4213+
42074214
public:
42084215
const TargetRelativeDirectPointer<Runtime, const void, /*nullable*/true> &
42094216
getResilientSuperclass() const {
@@ -4367,6 +4374,14 @@ class TargetClassDescriptor final
43674374
);
43684375
}
43694376

4377+
swift_once_t *getCanonicalMetadataPrespecializationCachingOnceToken() const {
4378+
if (!this->hasCanonicicalMetadataPrespecializations()) {
4379+
return nullptr;
4380+
}
4381+
auto box = this->template getTrailingObjects<MetadataCachingOnceToken>();
4382+
return box->token.get();
4383+
}
4384+
43704385
static bool classof(const TargetContextDescriptor<Runtime> *cd) {
43714386
return cd->getKind() == ContextDescriptorKind::Class;
43724387
}
@@ -4394,7 +4409,8 @@ class TargetStructDescriptor final
43944409
TargetForeignMetadataInitialization<Runtime>,
43954410
TargetSingletonMetadataInitialization<Runtime>,
43964411
TargetCanonicalSpecializedMetadatasListCount<Runtime>,
4397-
TargetCanonicalSpecializedMetadatasListEntry<Runtime>> {
4412+
TargetCanonicalSpecializedMetadatasListEntry<Runtime>,
4413+
TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>> {
43984414
public:
43994415
using ForeignMetadataInitialization =
44004416
TargetForeignMetadataInitialization<Runtime>;
@@ -4406,6 +4422,8 @@ class TargetStructDescriptor final
44064422
TargetCanonicalSpecializedMetadatasListCount<Runtime>;
44074423
using MetadataListEntry =
44084424
TargetCanonicalSpecializedMetadatasListEntry<Runtime>;
4425+
using MetadataCachingOnceToken =
4426+
TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>;
44094427

44104428
private:
44114429
using TrailingGenericContextObjects =
@@ -4414,7 +4432,8 @@ class TargetStructDescriptor final
44144432
ForeignMetadataInitialization,
44154433
SingletonMetadataInitialization,
44164434
MetadataListCount,
4417-
MetadataListEntry>;
4435+
MetadataListEntry,
4436+
MetadataCachingOnceToken>;
44184437

44194438
using TrailingObjects =
44204439
typename TrailingGenericContextObjects::TrailingObjects;
@@ -4444,6 +4463,10 @@ class TargetStructDescriptor final
44444463
: 0;
44454464
}
44464465

4466+
size_t numTrailingObjects(OverloadToken<MetadataCachingOnceToken>) const {
4467+
return this->hasCanonicicalMetadataPrespecializations() ? 1 : 0;
4468+
}
4469+
44474470
public:
44484471
using TrailingGenericContextObjects::getGenericContext;
44494472
using TrailingGenericContextObjects::getGenericContextHeader;
@@ -4489,6 +4512,14 @@ class TargetStructDescriptor final
44894512
);
44904513
}
44914514

4515+
swift_once_t *getCanonicalMetadataPrespecializationCachingOnceToken() const {
4516+
if (!this->hasCanonicicalMetadataPrespecializations()) {
4517+
return nullptr;
4518+
}
4519+
auto box = this->template getTrailingObjects<MetadataCachingOnceToken>();
4520+
return box->token.get();
4521+
}
4522+
44924523
static bool classof(const TargetContextDescriptor<Runtime> *cd) {
44934524
return cd->getKind() == ContextDescriptorKind::Struct;
44944525
}
@@ -4505,7 +4536,8 @@ class TargetEnumDescriptor final
45054536
TargetForeignMetadataInitialization<Runtime>,
45064537
TargetSingletonMetadataInitialization<Runtime>,
45074538
TargetCanonicalSpecializedMetadatasListCount<Runtime>,
4508-
TargetCanonicalSpecializedMetadatasListEntry<Runtime>> {
4539+
TargetCanonicalSpecializedMetadatasListEntry<Runtime>,
4540+
TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>> {
45094541
public:
45104542
using SingletonMetadataInitialization =
45114543
TargetSingletonMetadataInitialization<Runtime>;
@@ -4517,6 +4549,8 @@ class TargetEnumDescriptor final
45174549
TargetCanonicalSpecializedMetadatasListCount<Runtime>;
45184550
using MetadataListEntry =
45194551
TargetCanonicalSpecializedMetadatasListEntry<Runtime>;
4552+
using MetadataCachingOnceToken =
4553+
TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>;
45204554

45214555
private:
45224556
using TrailingGenericContextObjects =
@@ -4525,7 +4559,8 @@ class TargetEnumDescriptor final
45254559
ForeignMetadataInitialization,
45264560
SingletonMetadataInitialization,
45274561
MetadataListCount,
4528-
MetadataListEntry>;
4562+
MetadataListEntry,
4563+
MetadataCachingOnceToken>;
45294564

45304565
using TrailingObjects =
45314566
typename TrailingGenericContextObjects::TrailingObjects;
@@ -4555,6 +4590,10 @@ class TargetEnumDescriptor final
45554590
: 0;
45564591
}
45574592

4593+
size_t numTrailingObjects(OverloadToken<MetadataCachingOnceToken>) const {
4594+
return this->hasCanonicicalMetadataPrespecializations() ? 1 : 0;
4595+
}
4596+
45584597
public:
45594598
using TrailingGenericContextObjects::getGenericContext;
45604599
using TrailingGenericContextObjects::getGenericContextHeader;
@@ -4614,6 +4653,14 @@ class TargetEnumDescriptor final
46144653
);
46154654
}
46164655

4656+
swift_once_t *getCanonicalMetadataPrespecializationCachingOnceToken() const {
4657+
if (!this->hasCanonicicalMetadataPrespecializations()) {
4658+
return nullptr;
4659+
}
4660+
auto box = this->template getTrailingObjects<MetadataCachingOnceToken>();
4661+
return box->token.get();
4662+
}
4663+
46174664
static bool classof(const TargetContextDescriptor<Runtime> *cd) {
46184665
return cd->getKind() == ContextDescriptorKind::Enum;
46194666
}
@@ -4766,6 +4813,24 @@ TargetTypeContextDescriptor<Runtime>::getCanonicicalMetadataPrespecializations()
47664813
}
47674814
}
47684815

4816+
template <typename Runtime>
4817+
inline swift_once_t *TargetTypeContextDescriptor<
4818+
Runtime>::getCanonicalMetadataPrespecializationCachingOnceToken() const {
4819+
switch (this->getKind()) {
4820+
case ContextDescriptorKind::Enum:
4821+
return llvm::cast<TargetEnumDescriptor<Runtime>>(this)
4822+
->getCanonicalMetadataPrespecializationCachingOnceToken();
4823+
case ContextDescriptorKind::Struct:
4824+
return llvm::cast<TargetStructDescriptor<Runtime>>(this)
4825+
->getCanonicalMetadataPrespecializationCachingOnceToken();
4826+
case ContextDescriptorKind::Class:
4827+
return llvm::cast<TargetClassDescriptor<Runtime>>(this)
4828+
->getCanonicalMetadataPrespecializationCachingOnceToken();
4829+
default:
4830+
swift_unreachable("Not a type context descriptor.");
4831+
}
4832+
}
4833+
47694834
/// An entry in the chain of dynamic replacement functions.
47704835
struct DynamicReplacementChainEntry {
47714836
void *implementationFunction;

include/swift/ABI/MetadataValues.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -361,19 +361,7 @@ enum : unsigned {
361361
NumGenericMetadataPrivateDataWords = 16,
362362
};
363363

364-
/// Kinds of type metadata reocrds.
365-
enum class TypeMetadataRecordKind : unsigned {
366-
/// A direct reference to a nominal type descriptor.
367-
DirectTypeDescriptor = 0x00,
368-
369-
/// An indirect reference to a nominal type descriptor.
370-
IndirectTypeDescriptor = 0x01,
371-
372-
First_Kind = DirectTypeDescriptor,
373-
Last_Kind = IndirectTypeDescriptor,
374-
};
375-
376-
/// Kinds of references to type metadata.
364+
/// Kinds of type metadata/protocol conformance records.
377365
enum class TypeReferenceKind : unsigned {
378366
/// The conformance is for a nominal type referenced directly;
379367
/// getTypeDescriptor() points to the type context descriptor.
@@ -396,14 +384,10 @@ enum class TypeReferenceKind : unsigned {
396384
/// unused.
397385
IndirectObjCClass = 0x03,
398386

399-
/// The conformance is for a non-nominal type whose metadata kind we recorded;
400-
/// getMetadataKind() returns the kind.
401-
MetadataKind = 0x04,
402-
403387
// We only reserve three bits for this in the various places we store it.
404388

405389
First_Kind = DirectTypeDescriptor,
406-
Last_Kind = MetadataKind,
390+
Last_Kind = IndirectObjCClass,
407391
};
408392

409393
/// Flag that indicates whether an existential type is class-constrained or not.

include/swift/ABI/Task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class AsyncTask : public HeapObject, public Job {
182182
/// prevent it from being corrupted in flight.
183183
AsyncContext * __ptrauth_swift_task_resume_context ResumeContext;
184184

185-
/// The currntly-active information about cancellation.
185+
/// The currently-active information about cancellation.
186186
std::atomic<ActiveTaskStatus> Status;
187187

188188
/// Reserved for the use of the task-local stack allocator.

0 commit comments

Comments
 (0)