@@ -52,11 +52,11 @@ impl<E: Display> Display for AllocOrInitError<E> {
5252 }
5353}
5454
55- /// An arena to bump allocate into.
55+ /// An arena to allocate into.
5656///
5757/// # No `Drop`s
5858///
59- /// Objects that are bump- allocated will never have their [`Drop`] implementation
59+ /// Objects that are allocated will never have their [`Drop`] implementation
6060/// called — unless you do it manually yourself. This makes it relatively
6161/// easy to leak memory or other resources.
6262///
@@ -72,15 +72,15 @@ impl<E: Display> Display for AllocOrInitError<E> {
7272///
7373/// Potential solutions are:
7474///
75- /// * Using [`bumpalo::boxed ::Box::new_in`] instead of [`Arena::alloc`], that
75+ /// * Using [`oxc_allocator ::Box::new_in`] instead of [`Arena::alloc`], that
7676/// will drop wrapped values similarly to [`std::boxed::Box`]. Note that this
7777/// requires enabling the `"boxed"` Cargo feature for this crate. **This is
7878/// often the easiest solution.**
7979///
8080/// * Calling [`drop_in_place`][drop_in_place] or using
8181/// [`std::mem::ManuallyDrop`][manuallydrop] to manually drop these types.
8282///
83- /// * Using [`bumpalo::collections ::Vec`] instead of [`std::vec::Vec`].
83+ /// * Using [`oxc_allocator ::Vec`] instead of [`std::vec::Vec`].
8484///
8585/// * Avoiding allocating these problematic types within an `Arena`.
8686///
@@ -93,26 +93,26 @@ impl<E: Display> Display for AllocOrInitError<E> {
9393/// [`std::fs::File`]: https://doc.rust-lang.org/std/fs/struct.File.html
9494/// [drop_in_place]: https://doc.rust-lang.org/std/ptr/fn.drop_in_place.html
9595/// [manuallydrop]: https://doc.rust-lang.org/std/mem/struct.ManuallyDrop.html
96- /// [`bumpalo::collections:: Vec`]: collections/vec/struct. Vec.html
96+ /// [`oxc_allocator:: Vec`]: crate:: Vec
9797/// [`std::vec::Vec`]: https://doc.rust-lang.org/std/vec/struct.Vec.html
98- /// [`bumpalo::boxed:: Box::new_in`]: boxed/struct. Box.html#method. new_in
98+ /// [`oxc_allocator:: Box::new_in`]: crate:: Box:: new_in
9999/// [`std::boxed::Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html
100100///
101101/// # Example
102102///
103103/// ```
104104/// # use oxc_allocator::arena::Arena;
105105///
106- /// // Create a new bump arena.
106+ /// // Create a new arena.
107107/// let arena = Arena::new();
108108///
109109/// // Allocate values into the arena.
110110/// let forty_two = arena.alloc(42);
111111/// assert_eq!(*forty_two, 42);
112112///
113113/// // Mutable references are returned from allocation.
114- /// let mut s = arena.alloc("bumpalo" );
115- /// *s = "the bump allocator; and also is a buffalo" ;
114+ /// let mut n = arena.alloc(123u64 );
115+ /// *n = 456 ;
116116/// ```
117117///
118118/// # Allocation Methods Come in Many Flavors
@@ -252,9 +252,9 @@ impl<E: Display> Display for AllocOrInitError<E> {
252252///
253253/// ## `Arena` Allocation Limits
254254///
255- /// `bumpalo ` supports setting a limit on the maximum bytes of memory that can
255+ /// `Arena ` supports setting a limit on the maximum bytes of memory that can
256256/// be allocated for use in a particular `Arena` arena. This limit can be set and removed with
257- /// [`set_allocation_limit`][Arena::set_allocation_limit] .
257+ /// [`set_allocation_limit`].
258258/// The allocation limit is only enforced when allocating new backing chunks for
259259/// an `Arena`. Updating the allocation limit will not affect existing allocations
260260/// or any future allocations within the `Arena`'s current chunk.
@@ -285,6 +285,8 @@ impl<E: Display> Display for AllocOrInitError<E> {
285285/// Because of backwards compatibility, allocations that fail
286286/// due to allocation limits will not present differently than
287287/// errors due to resource exhaustion.
288+ ///
289+ /// [`set_allocation_limit`]: Arena::set_allocation_limit
288290#[ derive( Debug ) ]
289291pub struct Arena < const MIN_ALIGN : usize = 1 > {
290292 // The current chunk we are bump allocating within.
@@ -507,7 +509,7 @@ const OVERHEAD: usize = match round_up_to(MALLOC_OVERHEAD + CHUNK_FOOTER_SIZE, C
507509} ;
508510
509511// The target size of our first allocation, including our overhead.
510- // The available bump capacity will be slightly smaller.
512+ // The available capacity will be slightly smaller.
511513// 16 KiB covers the majority of real-world JS/TS files.
512514const FIRST_ALLOCATION_GOAL : usize = 16 * 1024 ;
513515
@@ -544,7 +546,7 @@ fn allocation_size_overflow<T>() -> T {
544546// workaround, other than putting constructors on the `Arena<DEFAULT>`; even
545547// `std` does this same thing with `HashMap`, for example.
546548impl Arena < 1 > {
547- /// Construct a new arena to bump allocate into.
549+ /// Construct a new arena to allocate into.
548550 ///
549551 /// # Example
550552 ///
@@ -557,7 +559,7 @@ impl Arena<1> {
557559 Self :: with_capacity ( 0 )
558560 }
559561
560- /// Attempt to construct a new arena to bump allocate into.
562+ /// Attempt to construct a new arena to allocate into.
561563 ///
562564 /// # Example
563565 ///
@@ -571,8 +573,7 @@ impl Arena<1> {
571573 Arena :: try_with_capacity ( 0 )
572574 }
573575
574- /// Construct a new arena with the specified byte capacity to bump allocate
575- /// into.
576+ /// Construct a new arena with the specified byte capacity to allocate into.
576577 ///
577578 /// # Example
578579 ///
@@ -589,8 +590,7 @@ impl Arena<1> {
589590 Self :: try_with_capacity ( capacity) . unwrap_or_else ( |_| oom ( ) )
590591 }
591592
592- /// Attempt to construct a new arena with the specified byte capacity to
593- /// bump allocate into.
593+ /// Attempt to construct a new arena with the specified byte capacity to allocate into.
594594 ///
595595 /// Propagates errors when allocating the initial capacity.
596596 ///
@@ -784,7 +784,7 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
784784 }
785785 }
786786
787- /// Get this bump arena's minimum alignment.
787+ /// Get this arena's minimum alignment.
788788 ///
789789 /// All objects allocated in this arena get aligned to this value.
790790 ///
@@ -977,14 +977,14 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
977977 }
978978 }
979979
980- /// Reset this bump allocator .
980+ /// Reset this arena .
981981 ///
982982 /// Performs mass deallocation on everything allocated in this arena by
983983 /// resetting the pointer into the underlying chunk of memory to the start
984984 /// of the chunk. Does not run any `Drop` implementations on deallocated
985985 /// objects; see [the top-level documentation](struct.Arena.html) for details.
986986 ///
987- /// If this arena has allocated multiple chunks to bump allocate into, then
987+ /// If this arena has allocated multiple chunks to allocate into, then
988988 /// the excess chunks are returned to the global allocator.
989989 ///
990990 /// # Example
@@ -2184,8 +2184,8 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
21842184 current_footer. ptr . get ( ) . as_ptr ( ) as usize - current_footer. data . as_ptr ( ) as usize
21852185 }
21862186
2187- /// Slow path allocation for when we need to allocate a new chunk from the
2188- /// parent bump set because there isn't enough room in our current chunk.
2187+ /// Slow path allocation for when we need to allocate a new chunk,
2188+ /// because there isn't enough room in our current chunk.
21892189 #[ inline( never) ]
21902190 #[ cold]
21912191 fn alloc_layout_slow ( & self , layout : Layout ) -> Option < NonNull < u8 > > {
@@ -2243,7 +2243,7 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
22432243 }
22442244
22452245 /// Returns an iterator over each chunk of allocated memory that
2246- /// this arena has bump allocated into.
2246+ /// this arena has allocated into.
22472247 ///
22482248 /// The chunks are returned ordered by allocation time, with the most
22492249 /// recently allocated chunk being returned first, and the least recently
@@ -2255,7 +2255,7 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
22552255 ///
22562256 /// # SAFETY
22572257 ///
2258- /// Because this method takes `&mut self`, we know that the bump arena
2258+ /// Because this method takes `&mut self`, we know that the arena
22592259 /// reference is unique and therefore there aren't any active references to
22602260 /// any of the objects we've allocated in it either. This potential aliasing
22612261 /// of exclusive references is one common footgun for unsafe code that we
@@ -2278,9 +2278,8 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
22782278 /// responsibility to ensure that these properties hold before calling
22792279 /// `MaybeUninit::assume_init` or otherwise reading the returned values.
22802280 ///
2281- /// Finally, you must also ensure that any values allocated into the bump
2282- /// arena have not had their `Drop` implementations called on them,
2283- /// e.g. after dropping a [`bumpalo::boxed::Box<T>`][crate::boxed::Box].
2281+ /// Finally, you must also ensure that any values allocated into the arena
2282+ /// have not had their `Drop` implementations called on them.
22842283 ///
22852284 /// # Example
22862285 ///
@@ -2289,13 +2288,13 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
22892288 ///
22902289 /// let mut arena = Arena::new();
22912290 ///
2292- /// // Allocate a bunch of `i32`s in this bump arena, potentially causing
2291+ /// // Allocate a bunch of `i32`s in this arena, potentially causing
22932292 /// // additional memory chunks to be reserved.
22942293 /// for i in 0..10000 {
22952294 /// arena.alloc(i);
22962295 /// }
22972296 ///
2298- /// // Iterate over each chunk we've bump allocated into. This is safe
2297+ /// // Iterate over each chunk we've allocated into. This is safe
22992298 /// // because we have only allocated `i32`s in this arena, which fulfills
23002299 /// // the above requirements.
23012300 /// for ch in arena.iter_allocated_chunks() {
@@ -2334,7 +2333,7 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
23342333 }
23352334
23362335 /// Returns an iterator over raw pointers to chunks of allocated memory that
2337- /// this arena has bump allocated into.
2336+ /// this arena has allocated into.
23382337 ///
23392338 /// This is an unsafe version of [`iter_allocated_chunks()`](Arena::iter_allocated_chunks),
23402339 /// with the caller responsible for safe usage of the returned pointers as
@@ -2355,16 +2354,16 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
23552354 }
23562355
23572356 /// Calculates the number of bytes currently allocated across all chunks in
2358- /// this bump arena.
2357+ /// this arena.
23592358 ///
23602359 /// If you allocate types of different alignments or types with
23612360 /// larger-than-typical alignment in the same arena, some padding
2362- /// bytes might get allocated in the bump arena. Note that those padding
2361+ /// bytes might get allocated in the arena. Note that those padding
23632362 /// bytes will add to this method's resulting sum, so you cannot rely
23642363 /// on it only counting the sum of the sizes of the things
23652364 /// you've allocated in the arena.
23662365 ///
2367- /// The allocated bytes do not include the size of bumpalo's metadata,
2366+ /// The allocated bytes do not include the size of arena metadata,
23682367 /// so the amount of memory requested from the Rust allocator is higher
23692368 /// than the returned value.
23702369 ///
@@ -2387,7 +2386,7 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
23872386 /// Calculates the number of bytes requested from the Rust allocator for this `Arena`.
23882387 ///
23892388 /// This number is equal to the [`allocated_bytes()`](Self::allocated_bytes) plus
2390- /// the size of the bump metadata.
2389+ /// the size of the metadata.
23912390 pub fn allocated_bytes_including_metadata ( & self ) -> usize {
23922391 let metadata_size =
23932392 unsafe { self . iter_allocated_chunks_raw ( ) . count ( ) * mem:: size_of :: < ChunkFooter > ( ) } ;
@@ -2695,7 +2694,7 @@ impl<const MIN_ALIGN: usize> Arena<MIN_ALIGN> {
26952694}
26962695
26972696/// An iterator over each chunk of allocated memory that
2698- /// an arena has bump allocated into.
2697+ /// an arena has allocated into.
26992698///
27002699/// The chunks are returned ordered by allocation time, with the most recently
27012700/// allocated chunk being returned first.
@@ -2729,7 +2728,7 @@ impl<'a, const MIN_ALIGN: usize> Iterator for ChunkIter<'a, MIN_ALIGN> {
27292728impl < const MIN_ALIGN : usize > iter:: FusedIterator for ChunkIter < ' _ , MIN_ALIGN > { }
27302729
27312730/// An iterator over raw pointers to chunks of allocated memory that this
2732- /// arena has bump allocated into.
2731+ /// arena has allocated into.
27332732///
27342733/// See [`ChunkIter`] for details regarding the returned chunks.
27352734///
@@ -2870,7 +2869,7 @@ unsafe impl<const MIN_ALIGN: usize> Allocator for &Arena<MIN_ALIGN> {
28702869
28712870// NB: Only tests which require private types, fields, or methods should be in
28722871// here. Anything that can just be tested via public API surface should be in
2873- // `bumpalo/ tests/all /*`.
2872+ // `tests/arena /*`.
28742873#[ cfg( test) ]
28752874mod tests {
28762875 use super :: * ;
0 commit comments