Commit f314efd
committed
[libcxx] adds a size-based representation for
**tl;dr** We can significantly improve the runtime performance of
`std::vector` by changing its representation from three pointers to one
pointer and two integers. This document explains the details of this
change, along with the justifications for making it. See the [RFC] for
more information.
This commit changes `std::vector`'s representation in a similar manner
to `__split_buffer` in #139632. We introduce a layout type that tracks
implementation details that differ between the pointer-based vector
and size-based vector representations. `vector` does not parameterise
its layout type, unlike `__split_buffer`. `__split_buffer` is used by
both `vector` and `deque`, and being able to take an ABI break on
`vector` doesn't automatically mean that users can also tolerate a break
on `deque`. The most convenient way to work around this problem is to
parameterise the layout type. Users of `std::vector` should not depend
on its layout, and libc++ has no internal reason to toggle it, so we
keep the representation concrete.
To use this feature, you'll need to configure libc++ so that it's built
with `-DLIBCXX_UNSTABLE_ABI=Yes`.
[RFC]: https://discourse.llvm.org/t/adding-a-size-based-vector-to-libc-s-unstable-abi/86306vector's unstable ABI1 parent 9fce004 commit f314efd
File tree
4 files changed
+596
-284
lines changed- libcxx
- include
- __vector
- test/std/algorithms/alg.modifying.operations/alg.swap
- utils/gdb/libcxx
4 files changed
+596
-284
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
272 | 271 | | |
273 | 272 | | |
274 | 273 | | |
| |||
277 | 276 | | |
278 | 277 | | |
279 | 278 | | |
280 | | - | |
281 | 279 | | |
282 | 280 | | |
283 | 281 | | |
| |||
316 | 314 | | |
317 | 315 | | |
318 | 316 | | |
319 | | - | |
320 | | - | |
321 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
322 | 320 | | |
323 | 321 | | |
324 | 322 | | |
| |||
0 commit comments