Skip to content

Commit 649c326

Browse files
authored
Merge pull request swiftlang#18959 from eeckstein/remove-rt-pinning
Remove pinning in reference counting and pinning runtime entry points
2 parents 724127b + 8f35a3e commit 649c326

File tree

17 files changed

+68
-580
lines changed

17 files changed

+68
-580
lines changed

docs/Runtime.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ Returns a random number. Only used by allocation profiling tools.
108108
000000000001cee0 T _swift_release_n
109109
000000000001ce30 T _swift_retain
110110
000000000001ce50 T _swift_retain_n
111-
000000000001d140 T _swift_tryPin
112111
000000000001d240 T _swift_tryRetain
113112
0000000000027b10 T _swift_unknownObjectRelease
114113
0000000000027a70 T _swift_unknownObjectRelease_n
@@ -140,7 +139,6 @@ Returns a random number. Only used by allocation profiling tools.
140139
000000000001d2b0 T _swift_unownedRetainStrong
141140
000000000001d310 T _swift_unownedRetainStrongAndRelease
142141
000000000001d060 T _swift_unownedRetain_n
143-
000000000001d1b0 T _swift_unpin
144142
000000000001ca20 T _swift_verifyEndOfLifetime
145143
000000000001d680 T _swift_weakAssign
146144
000000000001d830 T _swift_weakCopyAssign
@@ -154,10 +152,6 @@ Returns a random number. Only used by allocation profiling tools.
154152
000000000002afe0 T _swift_isUniquelyReferencedNonObjC
155153
000000000002af50 T _swift_isUniquelyReferencedNonObjC_nonNull
156154
000000000002b060 T _swift_isUniquelyReferencedNonObjC_nonNull_bridgeObject
157-
000000000002b200 T _swift_isUniquelyReferencedOrPinnedNonObjC_nonNull
158-
000000000002b130 T _swift_isUniquelyReferencedOrPinnedNonObjC_nonNull_bridgeObject
159-
000000000002b2f0 T _swift_isUniquelyReferencedOrPinned_native
160-
000000000002b290 T _swift_isUniquelyReferencedOrPinned_nonNull_native
161155
000000000002af00 T _swift_isUniquelyReferenced_native
162156
000000000002aea0 T _swift_isUniquelyReferenced_nonNull_native
163157
00000000000????? T _swift_setDeallocating

docs/StandardLibraryProgrammersManual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ TODO: Should this subsume or link to [AccessControlInStdlib.rst](https://github.
3737
1. `@inline(__always)` and `@inline(never)`
3838
1. `@semantics(...)`
3939
1. Builtins
40-
1. Builtin.addressof, _isUnique, _isUniqueOrPinned, etc
40+
1. Builtin.addressof, _isUnique, etc
4141
1. Dirty hacks
4242
1. Why all the underscores and extra protocols?
4343
1. How does the `...` ranges work?

include/swift/Runtime/HeapObject.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,6 @@ HeapObject *swift_tryRetain(HeapObject *object);
168168
SWIFT_RUNTIME_EXPORT
169169
bool swift_isDeallocating(HeapObject *object);
170170

171-
/// Attempts to atomically pin an object and increment its reference
172-
/// count. Returns nil if the object was already pinned.
173-
///
174-
/// The standard protocol is that the caller is responsible for
175-
/// calling swift_unpin on the return value.
176-
///
177-
/// The object reference may not be nil.
178-
SWIFT_RUNTIME_EXPORT
179-
HeapObject *swift_tryPin(HeapObject *object);
180-
181-
SWIFT_RUNTIME_EXPORT
182-
HeapObject *swift_nonatomic_tryPin(HeapObject *object);
183-
184-
/// Given that an object is pinned, atomically unpin it and decrement
185-
/// the reference count.
186-
///
187-
/// The object reference may be nil (to simplify the protocol).
188-
SWIFT_RUNTIME_EXPORT
189-
void swift_unpin(HeapObject *object);
190-
191-
SWIFT_RUNTIME_EXPORT
192-
void swift_nonatomic_unpin(HeapObject *object);
193-
194171
/// Atomically decrements the retain count of an object. If the
195172
/// retain count reaches zero, the object is destroyed as follows:
196173
///
@@ -244,44 +221,22 @@ bool swift_isUniquelyReferencedNonObjC(const void *);
244221
SWIFT_RUNTIME_EXPORT
245222
bool swift_isUniquelyReferencedNonObjC_nonNull(const void *);
246223

247-
/// Is this non-null pointer a reference to an object that uses Swift
248-
/// reference counting and is either uniquely referenced or pinned?
249-
SWIFT_RUNTIME_EXPORT
250-
bool swift_isUniquelyReferencedOrPinnedNonObjC_nonNull(const void *);
251-
252224
/// Is this non-null BridgeObject a unique reference to an object
253225
/// that uses Swift reference counting?
254226
SWIFT_RUNTIME_EXPORT
255227
bool swift_isUniquelyReferencedNonObjC_nonNull_bridgeObject(
256228
uintptr_t bits);
257229

258-
/// Is this non-null BridgeObject a unique or pinned reference to an
259-
/// object that uses Swift reference counting?
260-
SWIFT_RUNTIME_EXPORT
261-
bool swift_isUniquelyReferencedOrPinnedNonObjC_nonNull_bridgeObject(
262-
uintptr_t bits);
263-
264230
/// Is this native Swift pointer a non-null unique reference to
265231
/// an object?
266232
SWIFT_RUNTIME_EXPORT
267233
bool swift_isUniquelyReferenced_native(const struct HeapObject *);
268234

269-
/// Is this native Swift pointer a non-null unique or pinned reference
270-
/// to an object?
271-
SWIFT_RUNTIME_EXPORT
272-
bool swift_isUniquelyReferencedOrPinned_native(const struct HeapObject *);
273-
274235
/// Is this non-null native Swift pointer a unique reference to
275236
/// an object?
276237
SWIFT_RUNTIME_EXPORT
277238
bool swift_isUniquelyReferenced_nonNull_native(const struct HeapObject *);
278239

279-
/// Does this non-null native Swift pointer refer to an object that
280-
/// is either uniquely referenced or pinned?
281-
SWIFT_RUNTIME_EXPORT
282-
bool swift_isUniquelyReferencedOrPinned_nonNull_native(
283-
const struct HeapObject *);
284-
285240
/// Is this native Swift pointer non-null and has a reference count greater than
286241
/// one.
287242
/// This runtime call will print an error message with file name and location if

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,6 @@ FUNCTION(NativeNonAtomicStrongRetain, swift_nonatomic_retain, C_CC,
258258
ARGS(RefCountedPtrTy),
259259
ATTRS(NoUnwind, FirstParamReturned))
260260

261-
// void *swift_tryPin(void *ptr);
262-
FUNCTION(NativeTryPin, swift_tryPin, C_CC,
263-
RETURNS(RefCountedPtrTy),
264-
ARGS(RefCountedPtrTy),
265-
ATTRS(NoUnwind))
266-
267261
// void swift_nonatomic_release(void *ptr);
268262
FUNCTION(NativeNonAtomicStrongRelease, swift_nonatomic_release, C_CC,
269263
RETURNS(VoidTy),
@@ -276,30 +270,12 @@ FUNCTION(NativeTryRetain, swift_tryRetain, C_CC,
276270
ARGS(RefCountedPtrTy),
277271
ATTRS(NoUnwind))
278272

279-
// void swift_unpin(void *ptr);
280-
FUNCTION(NativeUnpin, swift_unpin, C_CC,
281-
RETURNS(VoidTy),
282-
ARGS(RefCountedPtrTy),
283-
ATTRS(NoUnwind))
284-
285273
// bool swift_isDeallocating(void *ptr);
286274
FUNCTION(IsDeallocating, swift_isDeallocating, C_CC,
287275
RETURNS(Int1Ty),
288276
ARGS(RefCountedPtrTy),
289277
ATTRS(NoUnwind, ZExt))
290278

291-
// void *swift_nonatomic_tryPin(void *ptr);
292-
FUNCTION(NonAtomicNativeTryPin, swift_nonatomic_tryPin, C_CC,
293-
RETURNS(RefCountedPtrTy),
294-
ARGS(RefCountedPtrTy),
295-
ATTRS(NoUnwind))
296-
297-
// void swift_nonatomic_unpin(void *ptr);
298-
FUNCTION(NonAtomicNativeUnpin, swift_nonatomic_unpin, C_CC,
299-
RETURNS(VoidTy),
300-
ARGS(RefCountedPtrTy),
301-
ATTRS(NoUnwind))
302-
303279
// void *swift_unknownObjectRetain(void *ptr);
304280
FUNCTION(UnknownObjectRetain, swift_unknownObjectRetain, C_CC,
305281
RETURNS(UnknownRefCountedPtrTy),
@@ -459,14 +435,6 @@ FUNCTION(IsUniquelyReferencedNonObjC_nonNull,
459435
ARGS(UnknownRefCountedPtrTy),
460436
ATTRS(NoUnwind, ZExt))
461437

462-
// bool swift_isUniquelyReferencedOrPinnedNonObjC_nonNull(const void *);
463-
FUNCTION(IsUniquelyReferencedOrPinnedNonObjC_nonNull,
464-
swift_isUniquelyReferencedOrPinnedNonObjC_nonNull,
465-
C_CC,
466-
RETURNS(Int1Ty),
467-
ARGS(UnknownRefCountedPtrTy),
468-
ATTRS(NoUnwind, ZExt))
469-
470438
// bool swift_isUniquelyReferencedNonObjC_nonNull_bridgeObject(
471439
// uintptr_t bits);
472440
FUNCTION(IsUniquelyReferencedNonObjC_nonNull_bridgeObject,
@@ -476,30 +444,13 @@ FUNCTION(IsUniquelyReferencedNonObjC_nonNull_bridgeObject,
476444
ARGS(BridgeObjectPtrTy),
477445
ATTRS(NoUnwind, ZExt))
478446

479-
// bool swift_isUniquelyReferencedOrPinnedNonObjC_nonNull_bridgeObject(
480-
// uintptr_t bits);
481-
FUNCTION(IsUniquelyReferencedOrPinnedNonObjC_nonNull_bridgeObject,
482-
swift_isUniquelyReferencedOrPinnedNonObjC_nonNull_bridgeObject,
483-
C_CC,
484-
RETURNS(Int1Ty),
485-
ARGS(BridgeObjectPtrTy),
486-
ATTRS(NoUnwind, ZExt))
487-
488447
// bool swift_isUniquelyReferenced_native(const struct HeapObject *);
489448
FUNCTION(IsUniquelyReferenced_native, swift_isUniquelyReferenced_native,
490449
C_CC,
491450
RETURNS(Int1Ty),
492451
ARGS(RefCountedPtrTy),
493452
ATTRS(NoUnwind, ZExt))
494453

495-
// bool swift_isUniquelyReferencedOrPinned_native(const struct HeapObject *);
496-
FUNCTION(IsUniquelyReferencedOrPinned_native,
497-
swift_isUniquelyReferencedOrPinned_native,
498-
C_CC,
499-
RETURNS(Int1Ty),
500-
ARGS(RefCountedPtrTy),
501-
ATTRS(NoUnwind, ZExt))
502-
503454
// bool swift_isUniquelyReferenced_nonNull_native(const struct HeapObject *);
504455
FUNCTION(IsUniquelyReferenced_nonNull_native,
505456
swift_isUniquelyReferenced_nonNull_native,
@@ -508,15 +459,6 @@ FUNCTION(IsUniquelyReferenced_nonNull_native,
508459
ARGS(RefCountedPtrTy),
509460
ATTRS(NoUnwind, ZExt))
510461

511-
// bool swift_isUniquelyReferencedOrPinned_nonNull_native(
512-
// const struct HeapObject *);
513-
FUNCTION(IsUniquelyReferencedOrPinned_nonNull_native,
514-
swift_isUniquelyReferencedOrPinned_nonNull_native,
515-
C_CC,
516-
RETURNS(Int1Ty),
517-
ARGS(RefCountedPtrTy),
518-
ATTRS(NoUnwind, ZExt))
519-
520462
// bool swift_isEscapingClosureAtFileLocation(const struct HeapObject *object,
521463
// const unsigned char *filename,
522464
// int32_t filenameLength,

include/swift/SIL/SILNode.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,6 @@ class alignas(8) SILNode {
221221
SWIFT_INLINE_BITFIELD(RefCountingInst, NonValueInstruction, 1,
222222
atomicity : 1
223223
);
224-
SWIFT_INLINE_BITFIELD(StrongPinInst, SingleValueInstruction, 1,
225-
atomicity : 1
226-
);
227224

228225
// Ensure that BindMemoryInst bitfield does not overflow.
229226
IBWTO_BITFIELD_EMPTY(BindMemoryInst, NonValueInstruction);

lib/IRGen/GenHeap.cpp

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,43 +1302,23 @@ llvm::Value *IRGenFunction::emitLoadRefcountedPtr(Address addr,
13021302
}
13031303

13041304
llvm::Value *IRGenFunction::
1305-
emitIsUniqueCall(llvm::Value *value, SourceLoc loc, bool isNonNull,
1306-
bool checkPinned) {
1305+
emitIsUniqueCall(llvm::Value *value, SourceLoc loc, bool isNonNull) {
13071306
llvm::Constant *fn;
13081307
if (value->getType() == IGM.RefCountedPtrTy) {
1309-
if (checkPinned) {
1310-
if (isNonNull)
1311-
fn = IGM.getIsUniquelyReferencedOrPinned_nonNull_nativeFn();
1312-
else
1313-
fn = IGM.getIsUniquelyReferencedOrPinned_nativeFn();
1314-
}
1315-
else {
1316-
if (isNonNull)
1317-
fn = IGM.getIsUniquelyReferenced_nonNull_nativeFn();
1318-
else
1319-
fn = IGM.getIsUniquelyReferenced_nativeFn();
1320-
}
1308+
if (isNonNull)
1309+
fn = IGM.getIsUniquelyReferenced_nonNull_nativeFn();
1310+
else
1311+
fn = IGM.getIsUniquelyReferenced_nativeFn();
13211312
} else if (value->getType() == IGM.UnknownRefCountedPtrTy) {
1322-
if (checkPinned) {
1323-
if (!isNonNull)
1324-
unimplemented(loc, "optional objc ref");
1325-
1326-
fn = IGM.getIsUniquelyReferencedOrPinnedNonObjC_nonNullFn();
1327-
}
1328-
else {
1329-
if (isNonNull)
1330-
fn = IGM.getIsUniquelyReferencedNonObjC_nonNullFn();
1331-
else
1332-
fn = IGM.getIsUniquelyReferencedNonObjCFn();
1333-
}
1313+
if (isNonNull)
1314+
fn = IGM.getIsUniquelyReferencedNonObjC_nonNullFn();
1315+
else
1316+
fn = IGM.getIsUniquelyReferencedNonObjCFn();
13341317
} else if (value->getType() == IGM.BridgeObjectPtrTy) {
13351318
if (!isNonNull)
13361319
unimplemented(loc, "optional bridge ref");
13371320

1338-
if (checkPinned)
1339-
fn = IGM.getIsUniquelyReferencedOrPinnedNonObjC_nonNull_bridgeObjectFn();
1340-
else
1341-
fn = IGM.getIsUniquelyReferencedNonObjC_nonNull_bridgeObjectFn();
1321+
fn = IGM.getIsUniquelyReferencedNonObjC_nonNull_bridgeObjectFn();
13421322
} else {
13431323
llvm_unreachable("Unexpected LLVM type for a refcounted pointer.");
13441324
}

lib/IRGen/IRGenFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class IRGenFunction {
430430
void emitErrorStrongRelease(llvm::Value *value);
431431

432432
llvm::Value *emitIsUniqueCall(llvm::Value *value, SourceLoc loc,
433-
bool isNonNull, bool checkPinned);
433+
bool isNonNull);
434434

435435
llvm::Value *emitIsEscapingClosureCall(llvm::Value *value, SourceLoc loc,
436436
unsigned verificationType);

lib/IRGen/IRGenSIL.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3914,7 +3914,7 @@ static bool hasReferenceSemantics(IRGenSILFunction &IGF,
39143914
}
39153915

39163916
static llvm::Value *emitIsUnique(IRGenSILFunction &IGF, SILValue operand,
3917-
SourceLoc loc, bool checkPinned) {
3917+
SourceLoc loc) {
39183918
if (!hasReferenceSemantics(IGF, operand->getType())) {
39193919
IGF.emitTrap(/*EmitUnreachable=*/false);
39203920
return llvm::UndefValue::get(IGF.IGM.Int1Ty);
@@ -3925,12 +3925,12 @@ static llvm::Value *emitIsUnique(IRGenSILFunction &IGF, SILValue operand,
39253925
operTI.loadRefcountedPtr(IGF, loc, IGF.getLoweredAddress(operand));
39263926

39273927
return
3928-
IGF.emitIsUniqueCall(ref.getValue(), loc, ref.isNonNull(), checkPinned);
3928+
IGF.emitIsUniqueCall(ref.getValue(), loc, ref.isNonNull());
39293929
}
39303930

39313931
void IRGenSILFunction::visitIsUniqueInst(swift::IsUniqueInst *i) {
39323932
llvm::Value *result = emitIsUnique(*this, i->getOperand(),
3933-
i->getLoc().getSourceLoc(), false);
3933+
i->getLoc().getSourceLoc());
39343934
Explosion out;
39353935
out.add(result);
39363936
setLoweredExplosion(i, out);

0 commit comments

Comments
 (0)