[swift-dev] statically initialized arrays

Andrew Trick atrick at apple.com
Thu Jun 15 23:04:06 CDT 2017

> On Jun 15, 2017, at 8:30 PM, Greg Parker <gparker at apple.com> wrote:
> (You can do without a separate token if (1) your storage is two pointers or less in size, (2) your storage is sufficiently well-aligned that it does not cross cache line boundaries, (3) your uninitialized value is zero, and (4) your initialized value is not zero. If all of these are true then you can perform the same trick that swift-once and dispatch-once use on the once token, but apply it directly to the data instead. And if your data is a single pointer you can do it faster than dispatch-once on weakly-ordered platforms that are not Alpha.)

That’s a good point. I’ll switch the runtime’s TLS key initialization over to that to save a load.

I assume the “two pointers or less” requirement is for an atomic store. And the single pointer requirement is for a barrier-free load? Although couldn’t you just atomically load two pointers?

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

More information about the swift-dev mailing list