> On Jun 19, 2017, at 9:58 AM, Joe Groff <jgr...@apple.com> wrote:
> 
>> On Jun 15, 2017, at 8:30 PM, Greg Parker via swift-dev <swift-dev@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     gpar...@apple.com <mailto:gpar...@apple.com>     Runtime 
Wrangler


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

Reply via email to