[swift-dev] Question about size of Character type

Chris Lattner clattner at apple.com
Sat Aug 20 20:25:07 CDT 2016


> On Aug 19, 2016, at 6:22 PM, Slava Pestov via swift-dev <swift-dev at swift.org> wrote:
> 
> 
>> On Aug 19, 2016, at 2:04 PM, Jordan Rose via swift-dev <swift-dev at swift.org <mailto:swift-dev at swift.org>> wrote:
>> 
>> We have an old Radar about this, rdar://problem/16754935 <rdar://problem/16754935>. It's probably just a case we're missing in enum layout. My guess is that it's because we don't have a whole spare bit in a RawPointer, but we should be able to pick some up either from alignment or from ABI knowledge.
>> 
>> Jordan
> 
> Hi Jordan,
> 
> I asked about a related issue, which is that RawPointer only has 1 extra inhabitant instead of 4096. You guys said you wanted non-zero integers to round-trip through RawPointer. It seems that declaring the high bits of a RawPointer as spare bits would cause the same problem as allowing more extra inhabitants.
> 
> Also I don’t think alignment is the answer here, RawPointer should be able to represent a char *, where you have no low spare bits.

On 64-bit systems, you can steal the top bits of pointers for other uses (but the value needs to be sign extended or masked out) since virtual address space is more limited than full 64-bits.

ARM64 even has a hardware feature for this, called “top byte ignored” (TBI) which means you don’t even have to do the masking.

-Chris

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


More information about the swift-dev mailing list