[libcxx] r180811 - This patch introduces an alternative layout for basic_string which when the string is short, the data pointer will be word-aligned. It can be activated with -D_LIBCPP_ALTERNATE_STRING_LAYOUT. These two different layouts (the default and _LIBCPP_ALTERNATE_STRING_LAYOUT) are not ABI compatible with each other. Once one is chosen for a given platform, it is disruptive to change it.

Howard Hinnant hhinnant at apple.com
Tue Apr 30 15:03:25 PDT 2013


On Apr 30, 2013, at 5:59 PM, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:

> On Tue, Apr 30, 2013 at 09:44:48PM -0000, Howard Hinnant wrote:
>> Author: hhinnant
>> Date: Tue Apr 30 16:44:48 2013
>> New Revision: 180811
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=180811&view=rev
>> Log:
>> This patch introduces an alternative layout for basic_string which when
>> the string is short, the data pointer will be word-aligned.  It can be
>> activated with -D_LIBCPP_ALTERNATE_STRING_LAYOUT.
> 
> What are the relative advantages of either?

The current layout, when the basic_string is short, has a data() pointer that is aligned to the alignment of the value_type (e.g. 1-byte aligned for string).  With _LIBCPP_ALTERNATE_STRING_LAYOUT, the same data() pointer will be 4-byte aligned on a 32 bit platform and 8-byte aligned on 64 bit platform.  When the string is long, there is no difference.  data() will be aligned to whatever the allocator returns (16-bytes on Apple platforms).

Howard




More information about the cfe-commits mailing list