[swift-dev] Questions about ARC

Jiho Choi jray319 at gmail.com
Wed Nov 30 10:33:04 CST 2016


I am new to Swift, and I have several questions about how ARC works in

1. I read from one of the previous discussions in the swift-evolution list (
that ARC operations are currently not atomic as Swift has no memory model
and concurrency model.  Does it mean that the compiler generates non-atomic
instructions for updating reference counts (e.g. using incrementNonAtomic()
instead of increment() in RefCount.h)?

2. If not, when does it use non-atomic ARC operations? Is there an
optimization pass to recognize local objects?

3. Without the concurrency model in the language, if not using GCD (e.g.
all Swift benchmark applications), I assume Swift applications are
single-threaded.  Then, I think we can safely use non-atomic ARC
operations.  Am I right?

4. Lastly, is there a way to measure the overhead of ARC (e.g. a compiler
flag to disable ARC)?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20161130/c92bff1a/attachment.html>

More information about the swift-dev mailing list