[llvm-arc-opts] Implement swift_{retain,release}_n.

rdar://21803771

Swift SVN r30204
This commit is contained in:
Michael Gottesman
2015-07-15 00:03:03 +00:00
parent 2315c8fd06
commit 4ce5cdad17
5 changed files with 97 additions and 1 deletions

View File

@@ -150,6 +150,8 @@ extern "C" void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask);
extern "C" HeapObject *swift_retain(HeapObject *object);
extern "C" void swift_retain_noresult(HeapObject *object);
extern "C" HeapObject *swift_retain_n(HeapObject *object, uint32_t n);
static inline HeapObject *_swift_retain_inlined(HeapObject *object) {
if (object) {
object->refCount.increment();
@@ -196,6 +198,10 @@ extern "C" void swift_unpin(HeapObject *object);
/// It's unlikely that a custom CC would be beneficial here.
extern "C" void swift_release(HeapObject *object);
/// Atomically decrements the retain count of an object n times. If the retain
/// count reaches zero, the object is destroyed
extern "C" void swift_release_n(HeapObject *object, uint32_t n);
/// ObjC compatibility. Never call this.
extern "C" size_t swift_retainCount(HeapObject *object);

View File

@@ -27,10 +27,11 @@ extern "C" HeapObject *(*_swift_allocObject)(HeapMetadata const *metadata,
extern "C" BoxPair::Return (*_swift_allocBox)(Metadata const *type);
extern "C" HeapObject *(*_swift_retain)(HeapObject *object);
extern "C" HeapObject *(*_swift_retain_n)(HeapObject *object, uint32_t n);
extern "C" HeapObject *(*_swift_tryRetain)(HeapObject *object);
extern "C" bool (*_swift_isDeallocating)(HeapObject *object);
extern "C" void (*_swift_release)(HeapObject *object);
extern "C" void (*_swift_release_n)(HeapObject *object, uint32_t n);
// liboainject on iOS 8 patches the function pointers below if present.
// Do not reuse these names unless you do what oainject expects you to do.