@@ -74,8 +74,6 @@ enum class IsaEncoding : uint8_t {
74
74
Unknown = ObjC,
75
75
};
76
76
77
- class ClassTypeInfo ;
78
-
79
77
// / HeapTypeInfo - A type designed for use implementing a type
80
78
// / which consists solely of something reference-counted.
81
79
// /
@@ -134,81 +132,35 @@ class HeapTypeInfo
134
132
135
133
// Emit the copy/destroy operations required by SingleScalarTypeInfo
136
134
// using strong reference counting.
137
- void emitScalarRelease (IRGenFunction &IGF, llvm::Value *value,
135
+ virtual void emitScalarRelease (IRGenFunction &IGF, llvm::Value *value,
138
136
Atomicity atomicity) const {
139
- if (asDerived ().getReferenceCounting () == ReferenceCounting::CxxCustom) {
140
- if constexpr (__is_same (Impl, ClassTypeInfo)) {
141
- auto releaseFn = findForeignReferenceTypeRefCountingOperation (
142
- asDerived ().getClass (),
143
- ForeignReferenceTypeRefCountingOperation::release);
144
- IGF.emitForeignReferenceTypeLifetimeOperation (releaseFn, value);
145
- return ;
146
- } else {
147
- llvm_unreachable (" " );
148
- }
149
- }
150
-
137
+ assert (asDerived ().getReferenceCounting () != ReferenceCounting::CxxCustom);
151
138
IGF.emitStrongRelease (value, asDerived ().getReferenceCounting (), atomicity);
152
139
}
153
140
154
141
void emitScalarFixLifetime (IRGenFunction &IGF, llvm::Value *value) const {
155
142
return IGF.emitFixLifetime (value);
156
143
}
157
144
158
- void emitScalarRetain (IRGenFunction &IGF, llvm::Value *value,
145
+ virtual void emitScalarRetain (IRGenFunction &IGF, llvm::Value *value,
159
146
Atomicity atomicity) const {
160
- if (asDerived ().getReferenceCounting () == ReferenceCounting::CxxCustom) {
161
- if constexpr (__is_same (Impl, ClassTypeInfo)) {
162
- auto releaseFn = findForeignReferenceTypeRefCountingOperation (
163
- asDerived ().getClass (),
164
- ForeignReferenceTypeRefCountingOperation::retain);
165
- IGF.emitForeignReferenceTypeLifetimeOperation (releaseFn, value);
166
- return ;
167
- } else {
168
- llvm_unreachable (" " );
169
- }
170
- }
171
-
147
+ assert (asDerived ().getReferenceCounting () != ReferenceCounting::CxxCustom);
172
148
IGF.emitStrongRetain (value, asDerived ().getReferenceCounting (), atomicity);
173
149
}
174
150
175
151
// Implement the primary retain/release operations of ReferenceTypeInfo
176
152
// using basic reference counting.
177
153
void strongRetain (IRGenFunction &IGF, Explosion &e,
178
154
Atomicity atomicity) const override {
155
+ assert (asDerived ().getReferenceCounting () != ReferenceCounting::CxxCustom);
179
156
llvm::Value *value = e.claimNext ();
180
-
181
- if (asDerived ().getReferenceCounting () == ReferenceCounting::CxxCustom) {
182
- if constexpr (__is_same (Impl, ClassTypeInfo)) {
183
- auto releaseFn = findForeignReferenceTypeRefCountingOperation (
184
- asDerived ().getClass (),
185
- ForeignReferenceTypeRefCountingOperation::retain);
186
- IGF.emitForeignReferenceTypeLifetimeOperation (releaseFn, value);
187
- return ;
188
- } else {
189
- llvm_unreachable (" " );
190
- }
191
- }
192
-
193
157
asDerived ().emitScalarRetain (IGF, value, atomicity);
194
158
}
195
159
196
160
void strongRelease (IRGenFunction &IGF, Explosion &e,
197
161
Atomicity atomicity) const override {
162
+ assert (asDerived ().getReferenceCounting () != ReferenceCounting::CxxCustom);
198
163
llvm::Value *value = e.claimNext ();
199
-
200
- if (asDerived ().getReferenceCounting () == ReferenceCounting::CxxCustom) {
201
- if constexpr (__is_same (Impl, ClassTypeInfo)) {
202
- auto releaseFn = findForeignReferenceTypeRefCountingOperation (
203
- asDerived ().getClass (),
204
- ForeignReferenceTypeRefCountingOperation::release);
205
- IGF.emitForeignReferenceTypeLifetimeOperation (releaseFn, value);
206
- return ;
207
- } else {
208
- llvm_unreachable (" " );
209
- }
210
- }
211
-
212
164
asDerived ().emitScalarRelease (IGF, value, atomicity);
213
165
}
214
166
0 commit comments