@@ -33,14 +33,12 @@ namespace quick_lint_js {
3333// * all allocations have the same alignment
3434//
3535// Internally, Linked_Bump_Allocator maintains a linked list of chunks.
36- template <std::size_t Alignment >
36+ template <std::size_t alignment >
3737class Linked_Bump_Allocator : public Memory_Resource {
3838 private:
3939 struct Chunk_Header ;
4040
4141 public:
42- static inline constexpr std::size_t alignment = Alignment;
43-
4442 explicit Linked_Bump_Allocator (const char * debug_owner) {
4543 static_cast <void >(debug_owner);
4644 }
@@ -134,7 +132,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
134132
135133 template <class T , class ... Args>
136134 T* new_object (Args&&... args) {
137- static_assert (alignof (T) <= Alignment ,
135+ static_assert (alignof (T) <= alignment ,
138136 " T is not allowed by this allocator; this allocator's "
139137 " alignment is insufficient for T" );
140138 constexpr std::size_t byte_size = align_up (sizeof (T));
@@ -143,7 +141,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
143141
144142 template <class T >
145143 [[nodiscard]] T* allocate_uninitialized_array (std::size_t size) {
146- static_assert (alignof (T) <= Alignment ,
144+ static_assert (alignof (T) <= alignment ,
147145 " T is not allowed by this allocator; this allocator's "
148146 " alignment is insufficient for T" );
149147 std::size_t byte_size = this ->align_up (size * sizeof (T));
@@ -206,12 +204,12 @@ class Linked_Bump_Allocator : public Memory_Resource {
206204
207205 protected:
208206 void * do_allocate (std::size_t bytes, std::size_t align) override {
209- QLJS_ASSERT (align <= Alignment );
207+ QLJS_ASSERT (align <= alignment );
210208 return this ->allocate_bytes (this ->align_up (bytes));
211209 }
212210
213211 void do_deallocate (void * p, std::size_t bytes, std::size_t align) override {
214- QLJS_ASSERT (align <= Alignment );
212+ QLJS_ASSERT (align <= alignment );
215213 this ->deallocate_bytes (p, bytes);
216214 }
217215
@@ -220,7 +218,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
220218 }
221219
222220 private:
223- struct alignas (maximum(Alignment , alignof (void *))) Chunk_Header {
221+ struct alignas (maximum(alignment , alignof (void *))) Chunk_Header {
224222 Chunk_Header* previous; // Linked list.
225223 std::size_t size; // Size of the data portion in bytes.
226224
@@ -234,7 +232,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
234232 }
235233
236234 static std::align_val_t allocation_alignment () noexcept {
237- return std::align_val_t {maximum (Alignment , alignof (Chunk_Header))};
235+ return std::align_val_t {maximum (alignment , alignof (Chunk_Header))};
238236 }
239237
240238 static Chunk_Header* new_chunk (std::size_t size, Chunk_Header* previous) {
@@ -243,7 +241,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
243241 ::operator new (allocation_size (size), allocation_alignment ());
244242#else
245243 void * chunk = ::operator new (allocation_size (size));
246- QLJS_ASSERT (is_aligned (chunk, Alignment ));
244+ QLJS_ASSERT (is_aligned (chunk, alignment ));
247245#endif
248246 return new (chunk) Chunk_Header{
249247 .previous = previous,
@@ -266,12 +264,12 @@ class Linked_Bump_Allocator : public Memory_Resource {
266264 4096 - sizeof (Chunk_Header);
267265
268266 static constexpr std::size_t align_up (std::size_t size) noexcept {
269- return (size + Alignment - 1 ) & ~(Alignment - 1 );
267+ return (size + alignment - 1 ) & ~(alignment - 1 );
270268 }
271269
272270 [[nodiscard]] void * allocate_bytes (std::size_t size) {
273271 this ->assert_not_disabled ();
274- QLJS_SLOW_ASSERT (size % Alignment == 0 );
272+ QLJS_SLOW_ASSERT (size % alignment == 0 );
275273 if (this ->remaining_bytes_in_current_chunk () < size) {
276274 this ->append_chunk (maximum (size, this ->default_chunk_size ));
277275 QLJS_ASSERT (this ->remaining_bytes_in_current_chunk () >= size);
0 commit comments