@@ -130,10 +130,24 @@ class LinkEntity {
130
130
// / is a ConstructorDecl* inside a class.
131
131
DispatchThunkInitializer,
132
132
133
- // / A method dispatch thunk for an allocating constructor. The pointer is a
134
- // / ConstructorDecl* inside a protocol or a class.
133
+ // / A method dispatch thunk for an allocating constructor. The pointer is
134
+ // / a ConstructorDecl* inside a protocol or a class.
135
135
DispatchThunkAllocator,
136
136
137
+ // / An async function pointer for a method dispatch thunk. The pointer is
138
+ // / a FuncDecl* inside a protocol or a class.
139
+ DispatchThunkAsyncFunctionPointer,
140
+
141
+ // / An async function pointer for a method dispatch thunk for an
142
+ // / initializing constructor. The pointer is a ConstructorDecl* inside a
143
+ // / class.
144
+ DispatchThunkInitializerAsyncFunctionPointer,
145
+
146
+ // / An async function pointer for a method dispatch thunk for an allocating
147
+ // / constructor. The pointer is a ConstructorDecl* inside a protocol or
148
+ // / a class.
149
+ DispatchThunkAllocatorAsyncFunctionPointer,
150
+
137
151
// / A method descriptor. The pointer is a FuncDecl* inside a protocol
138
152
// / or a class.
139
153
MethodDescriptor,
@@ -295,7 +309,7 @@ class LinkEntity {
295
309
296
310
// / The same as AsyncFunctionPointer but with a different stored value, for
297
311
// / use by TBDGen.
298
- // / The pointer is a AbstractStorageDecl *.
312
+ // / The pointer is an AbstractFunctionDecl *.
299
313
AsyncFunctionPointerAST,
300
314
301
315
// / The pointer is a SILFunction*.
@@ -861,7 +875,8 @@ class LinkEntity {
861
875
}
862
876
863
877
static LinkEntity
864
- forSILFunction (SILFunction *F, bool IsDynamicallyReplaceableImplementation) {
878
+ forSILFunction (SILFunction *F,
879
+ bool IsDynamicallyReplaceableImplementation=false ) {
865
880
LinkEntity entity;
866
881
entity.Pointer = F;
867
882
entity.SecondaryPointer = nullptr ;
@@ -1100,12 +1115,36 @@ class LinkEntity {
1100
1115
return entity;
1101
1116
}
1102
1117
1103
- static LinkEntity forAsyncFunctionPointer (SILFunction *silFunction ) {
1118
+ static LinkEntity forAsyncFunctionPointer (LinkEntity other ) {
1104
1119
LinkEntity entity;
1105
- entity.Pointer = silFunction ;
1120
+ entity.Pointer = other. Pointer ;
1106
1121
entity.SecondaryPointer = nullptr ;
1107
- entity.Data = LINKENTITY_SET_FIELD (
1108
- Kind, unsigned (LinkEntity::Kind::AsyncFunctionPointer));
1122
+
1123
+ switch (other.getKind ()) {
1124
+ case LinkEntity::Kind::SILFunction:
1125
+ entity.Data = LINKENTITY_SET_FIELD (
1126
+ Kind, unsigned (LinkEntity::Kind::AsyncFunctionPointer));
1127
+ break ;
1128
+
1129
+ case LinkEntity::Kind::DispatchThunk:
1130
+ entity.Data = LINKENTITY_SET_FIELD (
1131
+ Kind, unsigned (LinkEntity::Kind::DispatchThunkAsyncFunctionPointer));
1132
+ break ;
1133
+
1134
+ case LinkEntity::Kind::DispatchThunkInitializer:
1135
+ entity.Data = LINKENTITY_SET_FIELD (
1136
+ Kind, unsigned (LinkEntity::Kind::DispatchThunkInitializerAsyncFunctionPointer));
1137
+ break ;
1138
+
1139
+ case LinkEntity::Kind::DispatchThunkAllocator:
1140
+ entity.Data = LINKENTITY_SET_FIELD (
1141
+ Kind, unsigned (LinkEntity::Kind::DispatchThunkAllocatorAsyncFunctionPointer));
1142
+ break ;
1143
+
1144
+ default :
1145
+ llvm_unreachable (" Link entity kind cannot have an async function pointer" );
1146
+ }
1147
+
1109
1148
return entity;
1110
1149
}
1111
1150
@@ -1115,6 +1154,39 @@ class LinkEntity {
1115
1154
return entity;
1116
1155
}
1117
1156
1157
+ LinkEntity getUnderlyingEntityForAsyncFunctionPointer () const {
1158
+ LinkEntity entity;
1159
+ entity.Pointer = Pointer;
1160
+ entity.SecondaryPointer = nullptr ;
1161
+
1162
+ switch (getKind ()) {
1163
+ case LinkEntity::Kind::AsyncFunctionPointer:
1164
+ entity.Data = LINKENTITY_SET_FIELD (
1165
+ Kind, unsigned (LinkEntity::Kind::SILFunction));
1166
+ break ;
1167
+
1168
+ case LinkEntity::Kind::DispatchThunkAsyncFunctionPointer:
1169
+ entity.Data = LINKENTITY_SET_FIELD (
1170
+ Kind, unsigned (LinkEntity::Kind::DispatchThunk));
1171
+ break ;
1172
+
1173
+ case LinkEntity::Kind::DispatchThunkInitializerAsyncFunctionPointer:
1174
+ entity.Data = LINKENTITY_SET_FIELD (
1175
+ Kind, unsigned (LinkEntity::Kind::DispatchThunkInitializer));
1176
+ break ;
1177
+
1178
+ case LinkEntity::Kind::DispatchThunkAllocatorAsyncFunctionPointer:
1179
+ entity.Data = LINKENTITY_SET_FIELD (
1180
+ Kind, unsigned (LinkEntity::Kind::DispatchThunkAllocator));
1181
+ break ;
1182
+
1183
+ default :
1184
+ llvm_unreachable (" Link entity is not an async function pointer" );
1185
+ }
1186
+
1187
+ return entity;
1188
+ }
1189
+
1118
1190
void mangle (llvm::raw_ostream &out) const ;
1119
1191
void mangle (SmallVectorImpl<char > &buffer) const ;
1120
1192
std::string mangleAsString () const ;
0 commit comments