mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Merge pull request #13953 from xokdvium/value-alignment
libexpr: Overalign Value to 16 bytes
This commit is contained in:
commit
3c331b7ef3
2 changed files with 15 additions and 2 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# include <gc/gc_allocator.h>
|
# include <gc/gc_allocator.h>
|
||||||
|
# include <gc/gc_tiny_fl.h> // For GC_GRANULE_BYTES
|
||||||
|
|
||||||
# include <boost/coroutine2/coroutine.hpp>
|
# include <boost/coroutine2/coroutine.hpp>
|
||||||
# include <boost/coroutine2/protected_fixedsize_stack.hpp>
|
# include <boost/coroutine2/protected_fixedsize_stack.hpp>
|
||||||
|
|
@ -23,6 +24,17 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure that Boehm satisfies our alignment requirements. This is the default configuration [^]
|
||||||
|
* and this assertion should never break for any platform. Let's assert it just in case.
|
||||||
|
*
|
||||||
|
* This alignment is particularly useful to be able to use aligned
|
||||||
|
* load/store instructions for loading/writing Values.
|
||||||
|
*
|
||||||
|
* [^]: https://github.com/bdwgc/bdwgc/blob/54ac18ccbc5a833dd7edaff94a10ab9b65044d61/include/gc/gc_tiny_fl.h#L31-L33
|
||||||
|
*/
|
||||||
|
static_assert(sizeof(void *) * 2 == GC_GRANULE_BYTES, "Boehm GC must use GC_GRANULE_WORDS = 2");
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
#if NIX_USE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ namespace detail {
|
||||||
/* Whether to use a specialization of ValueStorage that does bitpacking into
|
/* Whether to use a specialization of ValueStorage that does bitpacking into
|
||||||
alignment niches. */
|
alignment niches. */
|
||||||
template<std::size_t ptrSize>
|
template<std::size_t ptrSize>
|
||||||
inline constexpr bool useBitPackedValueStorage = (ptrSize == 8) && (__STDCPP_DEFAULT_NEW_ALIGNMENT__ >= 8);
|
inline constexpr bool useBitPackedValueStorage = (ptrSize == 8) && (__STDCPP_DEFAULT_NEW_ALIGNMENT__ >= 16);
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
|
@ -378,7 +378,8 @@ inline constexpr bool useBitPackedValueStorage = (ptrSize == 8) && (__STDCPP_DEF
|
||||||
* Packs discriminator bits into the pointer alignment niches.
|
* Packs discriminator bits into the pointer alignment niches.
|
||||||
*/
|
*/
|
||||||
template<std::size_t ptrSize>
|
template<std::size_t ptrSize>
|
||||||
class ValueStorage<ptrSize, std::enable_if_t<detail::useBitPackedValueStorage<ptrSize>>> : public detail::ValueBase
|
class alignas(16) ValueStorage<ptrSize, std::enable_if_t<detail::useBitPackedValueStorage<ptrSize>>>
|
||||||
|
: public detail::ValueBase
|
||||||
{
|
{
|
||||||
/* Needs a dependent type name in order for member functions (and
|
/* Needs a dependent type name in order for member functions (and
|
||||||
* potentially ill-formed bit casts) to be SFINAE'd out.
|
* potentially ill-formed bit casts) to be SFINAE'd out.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue