if we define a TraceableAllocator at all times and use that in places that want maybe-traceable allocation we can simplify things a lot. we also unconditionally allocate cache root pointers for Value and Env-1 caches, even though we don't need them without gc (they're so cheap). defaulting to `std::allocator` without gc recovers previous behavior. Change-Id: I236da8c3b0669b40cdfe355ec3ec4e764d096074
32 lines
727 B
C++
32 lines
727 B
C++
#pragma once
|
|
///@file
|
|
|
|
#include "gc-alloc.hh"
|
|
#include <boost/container/small_vector.hpp>
|
|
|
|
namespace nix {
|
|
|
|
struct Value;
|
|
|
|
/**
|
|
* A GC compatible vector that may used a reserved portion of `nItems` on the stack instead of allocating on the heap.
|
|
*/
|
|
template <typename T, size_t nItems>
|
|
using SmallVector = boost::container::small_vector<T, nItems, TraceableAllocator<T>>;
|
|
|
|
/**
|
|
* A vector of value pointers. See `SmallVector`.
|
|
*/
|
|
template <size_t nItems>
|
|
using SmallValueVector = SmallVector<Value *, nItems>;
|
|
|
|
/**
|
|
* A vector of values that must not be referenced after the vector is destroyed.
|
|
*
|
|
* See also `SmallValueVector`.
|
|
*/
|
|
template <size_t nItems>
|
|
using SmallTemporaryValueVector = SmallVector<Value, nItems>;
|
|
|
|
}
|