<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: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 style="" class=""><blockquote type="cite" 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="">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 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=""><span 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;" class="">Sorry, I spoke too generally. Obviously, this is a platform/kernel-specific</span><br 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=""><span 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;" class="">decision. *Darwin* guarantees that the top eight bits are clear on userspace</span><br 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=""><span 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;" class="">data pointers on both ARM64 and x86-64. If Linux makes weaker guarantees,</span><br 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=""><span 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;" class="">which seems likely to me, then we should make weaker assumptions on Linux.</span><br 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=""></div></div></blockquote></div><br class=""><div class="">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 class=""><br class=""></div><div class="">-Joe</div></body></html>