[swift-dev] statically initialized arrays

Greg Parker gparker at apple.com
Mon Jun 19 15:01:05 CDT 2017

> On Jun 19, 2017, at 9:58 AM, Joe Groff <jgroff at apple.com> wrote:
>> On Jun 15, 2017, at 8:30 PM, Greg Parker via swift-dev <swift-dev at swift.org> wrote:
>> swift_once is not the most efficient solution here - we don't need separate once token storage in this case - but it's fine for now. If necessary we can get rid of the once token requirement in a backwards-compatible way.
>> (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.)
> Does the transition have to be strictly zero -> nonzero? I thought it just had to be "original value at the time page was mapped into process" -> "something else". For metadata initialization on 64-bit Apple, we could perhaps go from relative offset of metadata accessor function (which should always be <2GB in Mach-O) to absolute metadata address (which should always be >4GB on 64-bit Darwin).

That ought to work too. 

Greg Parker     gparker at apple.com <mailto:gparker at apple.com>     Runtime Wrangler

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

More information about the swift-dev mailing list