Skip to content

Commit c0ba520

Browse files
Merge pull request #79781 from nate-chandler/general-coro/20250227/1
[CoroutineAccessors] Dispatch and PtrAuth.
2 parents b6b4a7b + 6581fec commit c0ba520

Some content is hidden

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

45 files changed

+742
-173
lines changed

docs/ABI/Mangling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ types where the metadata itself has unknown layout.)
235235
global ::= global 'TF' // distributed method accessor
236236
global ::= global 'TI' // implementation of a dynamic_replaceable function
237237
global ::= global 'Tu' // async function pointer of a function
238-
global ::= global 'Tv' // coro function pointer of a function
239238
global ::= global 'TX' // function pointer of a dynamic_replaceable function
240239
global ::= global 'Twb' // back deployment thunk
241240
global ::= global 'TwB' // back deployment fallback function
241+
global ::= global 'Twc' // coro function pointer of a function
242242
global ::= entity entity 'TV' // vtable override thunk, derived followed by base
243243
global ::= type label-list? 'D' // type mangling for the debugger with label list for function types.
244244
global ::= type 'TC' // continuation prototype (not actually used for real symbols)

include/swift/ABI/Metadata.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5094,9 +5094,9 @@ struct DynamicReplacementKey {
50945094
uint16_t getExtraDiscriminator() const {
50955095
return flags & 0x0000FFFF;
50965096
}
5097-
bool isAsync() const {
5098-
return ((flags >> 16 ) & 0x1);
5099-
}
5097+
bool isAsync() const { return ((flags >> 16) & 0x1); }
5098+
bool isCalleeAllocatedCoroutine() const { return ((flags >> 16) & 0x2); }
5099+
bool isData() const { return isAsync() || isCalleeAllocatedCoroutine(); }
51005100
};
51015101

51025102
/// A record describing a dynamic function replacement.

include/swift/ABI/MetadataValues.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,23 @@ class MethodDescriptorFlags {
438438

439439
bool isAsync() const { return Value & IsAsyncMask; }
440440

441+
bool isCalleeAllocatedCoroutine() const {
442+
switch (getKind()) {
443+
case Kind::Method:
444+
case Kind::Init:
445+
case Kind::Getter:
446+
case Kind::Setter:
447+
case Kind::ModifyCoroutine:
448+
case Kind::ReadCoroutine:
449+
return false;
450+
case Kind::Read2Coroutine:
451+
case Kind::Modify2Coroutine:
452+
return true;
453+
}
454+
}
455+
456+
bool isData() const { return isAsync() || isCalleeAllocatedCoroutine(); }
457+
441458
uint16_t getExtraDiscriminator() const {
442459
return (Value >> ExtraDiscriminatorShift);
443460
}
@@ -649,6 +666,26 @@ class ProtocolRequirementFlags {
649666

650667
bool isAsync() const { return Value & IsAsyncMask; }
651668

669+
bool isCalleeAllocatedCoroutine() const {
670+
switch (getKind()) {
671+
case Kind::BaseProtocol:
672+
case Kind::Method:
673+
case Kind::Init:
674+
case Kind::Getter:
675+
case Kind::Setter:
676+
case Kind::ReadCoroutine:
677+
case Kind::ModifyCoroutine:
678+
case Kind::AssociatedTypeAccessFunction:
679+
case Kind::AssociatedConformanceAccessFunction:
680+
return false;
681+
case Kind::Read2Coroutine:
682+
case Kind::Modify2Coroutine:
683+
return true;
684+
}
685+
}
686+
687+
bool isData() const { return isAsync() || isCalleeAllocatedCoroutine(); }
688+
652689
bool isSignedWithAddress() const {
653690
return getKind() != Kind::BaseProtocol;
654691
}

include/swift/AST/IRGenOptions.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,26 @@ struct PointerAuthOptions : clang::PointerAuthOptions {
230230

231231
/// Type layout string descriminator.
232232
PointerAuthSchema TypeLayoutString;
233+
234+
/// Like SwiftFunctionPointers but for use with CoroFunctionPointer values.
235+
PointerAuthSchema CoroSwiftFunctionPointers;
236+
237+
/// Like SwiftClassMethods but for use with CoroFunctionPointer values.
238+
PointerAuthSchema CoroSwiftClassMethods;
239+
240+
/// Like ProtocolWitnesses but for use with CoroFunctionPointer values.
241+
PointerAuthSchema CoroProtocolWitnesses;
242+
243+
/// Like SwiftClassMethodPointers but for use with CoroFunctionPointer
244+
/// values.
245+
PointerAuthSchema CoroSwiftClassMethodPointers;
246+
247+
/// Like SwiftDynamicReplacements but for use with CoroFunctionPointer
248+
/// values.
249+
PointerAuthSchema CoroSwiftDynamicReplacements;
250+
251+
/// Like PartialApplyCapture but for use with CoroFunctionPointer values.
252+
PointerAuthSchema CoroPartialApplyCapture;
233253
};
234254

235255
enum class JITDebugArtifact : unsigned {
@@ -502,9 +522,6 @@ class IRGenOptions {
502522
// Whether to emit typed malloc during coroutine frame allocation.
503523
unsigned EmitTypeMallocForCoroFrame : 1;
504524

505-
// Whether to use the yield_once ABI when emitting yield_once_2 coroutines.
506-
unsigned EmitYieldOnce2AsYieldOnce : 1;
507-
508525
// Whether to force emission of a frame for all async functions
509526
// (LLVM's 'frame-pointer=all').
510527
unsigned AsyncFramePointerAll : 1;
@@ -621,9 +638,9 @@ class IRGenOptions {
621638
ColocateTypeDescriptors(true), UseRelativeProtocolWitnessTables(false),
622639
UseFragileResilientProtocolWitnesses(false), EnableHotColdSplit(false),
623640
EmitAsyncFramePushPopMetadata(true), EmitTypeMallocForCoroFrame(false),
624-
EmitYieldOnce2AsYieldOnce(true), AsyncFramePointerAll(false),
625-
UseProfilingMarkerThunks(false), UseCoroCCX8664(false),
626-
UseCoroCCArm64(false), DebugInfoForProfiling(false), CmdArgs(),
641+
AsyncFramePointerAll(false), UseProfilingMarkerThunks(false),
642+
UseCoroCCX8664(false), UseCoroCCArm64(false),
643+
DebugInfoForProfiling(false), CmdArgs(),
627644
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
628645
TypeInfoFilter(TypeInfoDumpFilter::All),
629646
PlatformCCallingConvention(llvm::CallingConv::C), UseCASBackend(false),

include/swift/Basic/Features.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CoroutineAccessors, true)
477477
/// modify/read single-yield coroutines always execute code post-yield code
478478
EXPERIMENTAL_FEATURE(CoroutineAccessorsUnwindOnCallerError, false)
479479

480-
/// modify/read coroutines use the callee-allocated ABI
481-
EXPERIMENTAL_FEATURE(CoroutineAccessorsAllocateInCallee, false)
482-
483480
/// When a parameter has unspecified isolation, infer it as main actor isolated.
484481
EXPERIMENTAL_FEATURE(GenerateForceToMainActorThunks, false)
485482

include/swift/Demangling/DemangleNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ NODE(DependentGenericInverseConformanceRequirement)
408408
NODE(Integer)
409409
NODE(NegativeInteger)
410410
NODE(DependentGenericParamValueMarker)
411+
NODE(CoroFunctionPointer)
411412

412413
#undef CONTEXT_NODE
413414
#undef NODE

include/swift/IRGen/Linking.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,11 @@ class LinkEntity {
585585
/// The pointer is the llvm::Function* for a partial apply forwarder.
586586
PartialApplyForwarderCoroFunctionPointer,
587587

588+
/// An coro function pointer to a function which is known to exist whose
589+
/// name is known.
590+
/// The pointer is a const char* of the name.
591+
KnownCoroFunctionPointer,
592+
588593
/// An coro function pointer for a distributed accessor (method or
589594
/// property).
590595
/// The pointer is a SILFunction*.
@@ -1553,6 +1558,15 @@ class LinkEntity {
15531558
return entity;
15541559
}
15551560

1561+
static LinkEntity forKnownCoroFunctionPointer(const char *name) {
1562+
LinkEntity entity;
1563+
entity.Pointer = const_cast<char *>(name);
1564+
entity.SecondaryPointer = nullptr;
1565+
entity.Data =
1566+
LINKENTITY_SET_FIELD(Kind, unsigned(Kind::KnownCoroFunctionPointer));
1567+
return entity;
1568+
}
1569+
15561570
LinkEntity getUnderlyingEntityForCoroFunctionPointer() const {
15571571
LinkEntity entity;
15581572
entity.Pointer = Pointer;

include/swift/SIL/SILDeclRef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ struct SILDeclRef {
605605
}
606606

607607
bool hasAsync() const;
608+
bool isCalleeAllocatedCoroutine() const;
608609

609610
/// Return the hash code for the SIL declaration.
610611
friend llvm::hash_code hash_value(swift::SILDeclRef ref) {

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10931,7 +10931,7 @@ bool AccessorDecl::isRequirementWithSynthesizedDefaultImplementation() const {
1093110931
if (!requiresFeatureCoroutineAccessors(getAccessorKind())) {
1093210932
return false;
1093310933
}
10934-
if (getStorage()->getOverrideLoc()) {
10934+
if (!requiresNewWitnessTableEntry()) {
1093510935
return false;
1093610936
}
1093710937
return getStorage()->requiresCorrespondingUnderscoredCoroutineAccessor(

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ UNINTERESTING_FEATURE(SafeInteropWrappers)
392392
UNINTERESTING_FEATURE(AssumeResilientCxxTypes)
393393
UNINTERESTING_FEATURE(ImportNonPublicCxxMembers)
394394
UNINTERESTING_FEATURE(CoroutineAccessorsUnwindOnCallerError)
395-
UNINTERESTING_FEATURE(CoroutineAccessorsAllocateInCallee)
396395

397396
bool swift::usesFeatureIsolatedDeinit(const Decl *decl) {
398397
if (auto cd = dyn_cast<ClassDecl>(decl)) {

0 commit comments

Comments
 (0)