<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 8, 2016, at 1:48 PM, Joe Groff via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Mar 8, 2016, at 1:04 PM, John McCall via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Mar 8, 2016, at 2:24 AM, Bryan Chan <<a href="mailto:bryan.chan@ca.ibm.com" class="">bryan.chan@ca.ibm.com</a>> wrote:<br class="">John McCall via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote on 2016-03-01 06:23:24 PM:<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On Mar 1, 2016, at 3:05 PM, Greg Parker via swift-dev <swift-<br class=""></blockquote><a href="mailto:dev@swift.org" class="">dev@swift.org</a>> wrote:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On Mar 1, 2016, at 1:33 PM, Joe Groff via swift-dev <swift-<br class=""></blockquote></blockquote><a href="mailto:dev@swift.org" class="">dev@swift.org</a>> wrote:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class="">In swift_retain/release, we have an early-exit check to pass<span class="Apple-converted-space"> </span><br class=""></blockquote></blockquote>through a nil pointer. Since we're already burning branch, I'm<span class="Apple-converted-space"> </span><br class="">thinking we could pass through not only zero but negative pointer<span class="Apple-converted-space"> </span><br class="">values too on 64-bit systems, since negative pointers are never<span class="Apple-converted-space"> </span><br class="">valid userspace pointers on our 64-bit targets. This would give us<span class="Apple-converted-space"> </span><br class="">room for tagged-pointer-like optimizations, for instance to avoid<span class="Apple-converted-space"> </span><br class="">allocations for tiny closure contexts.<br class=""><blockquote type="cite" class=""><br class="">We can't do that unless we can get a guarantee from the OS folks<span class="Apple-converted-space"> </span><br class=""></blockquote>that a "negative" pointer will never be a valid userspace pointer in<br class="">any future OS version.<br class=""><br class="">We have that guarantee, actually. The top eight bits are guaranteed<br class="">to be clear in the user space on both ARM64 and x86-64.<br class=""></blockquote><br class="">This may be the case currently on Linux (even for non-x86 architectures),<br class="">but what I have heard is that the kernel architecture allows using more<br class="">levels of page tables, and the full 64-bit address space. The "guarantee"<br class="">may not hold true in the future.<br class=""><br class="">Negative pointer values are also used on other operating systems, so I<br class="">would suggest not relying on this assumption for the sake of portability.<br class=""></blockquote><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">Sorry, I spoke too generally. Obviously, this is a platform/kernel-specific</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">decision. *Darwin* guarantees that the top eight bits are clear on userspace</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">data pointers on both ARM64 and x86-64. If Linux makes weaker guarantees,</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">which seems likely to me, then we should make weaker assumptions on Linux.</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div></div></blockquote></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Yeah, this would be a platform-specific decision. Linux x86-64 userspace at least still keeps to the positive side, since IIRC that's specified by the x86-64 SysV ABI, isn't it Bryan?</div></div></blockquote><br class=""></div><div>This could be further constrained to *refcountable* pointers if necessary. Even if the kernel for some reason decided to vend kernel-space addresses to userspace, it seems highly unlikely to me that address would point to a Swift-refcountable object.</div><div><br class=""></div><div>-Joe</div><br class=""></body></html>