> On Jun 15, 2017, at 8:30 PM, Greg Parker <gpar...@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?

-Andy
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to