oxc_allocator/lib.rs
1//! # ⚓ Oxc Memory Allocator
2//!
3//! Oxc uses a bump-based memory arena for faster AST allocations.
4//!
5//! This crate contains an [`Allocator`] for creating such arenas, as well as ports of data types
6//! from `std` adapted to use this arena:
7//!
8//! * [`Box`]
9//! * [`Vec`]
10//! * [`String`]
11//! * [`HashMap`]
12//! * [`HashSet`]
13//!
14//! See [`Allocator`] docs for information on efficient use of [`Allocator`].
15//!
16//! ## Features
17//!
18//! * `serialize` - Enables serialization support for [`Box`] and [`Vec`] with `serde` and `oxc_estree`.
19//!
20//! * `pool` - Enables `AllocatorPool`.
21//!
22//! * `bitset` - Enables `BitSet`.
23//!
24//! * `from_raw_parts` - Adds `Allocator::from_raw_parts` method.
25//! Usage of this feature is not advisable, and it will be removed as soon as we're able to.
26//!
27//! * `fixed_size` - Makes `AllocatorPool` create large fixed-size allocators, instead of
28//! flexibly-sized ones.
29//! Only supported on 64-bit little-endian platforms at present.
30//! Usage of this feature is not advisable, and it will be removed as soon as we're able to.
31//!
32//! * `track_allocations` - Count allocations and reallocations.
33//! For internal use only. The APIs provided by this feature are sketchy at best, and possibly
34//! undefined behavior. Do not enable this feature under any circumstances in production code.
35//!
36//! * `disable_track_allocations` - Disables `track_allocations` feature.
37//! Purpose is to prevent `--all-features` enabling allocation tracking.
38
39mod accessor;
40mod address;
41mod alloc;
42mod allocator;
43mod allocator_api2;
44#[cfg(feature = "bitset")]
45mod bitset;
46mod boxed;
47pub(crate) mod bump;
48pub(crate) mod bumpalo_alloc;
49mod clone_in;
50mod convert;
51#[cfg(feature = "from_raw_parts")]
52mod from_raw_parts;
53pub mod hash_map;
54pub mod hash_set;
55pub mod ident_hasher;
56#[cfg(feature = "pool")]
57mod pool;
58mod string_builder;
59mod take_in;
60#[cfg(all(feature = "track_allocations", not(feature = "disable_track_allocations")))]
61mod tracking;
62mod vec;
63mod vec2;
64
65pub use accessor::AllocatorAccessor;
66pub use address::{Address, GetAddress, UnstableAddress};
67pub use allocator::Allocator;
68#[cfg(feature = "bitset")]
69pub use bitset::BitSet;
70pub use boxed::Box;
71pub use clone_in::CloneIn;
72pub use convert::{FromIn, IntoIn};
73pub use hash_map::HashMap;
74pub use hash_set::HashSet;
75pub use ident_hasher::{IdentBuildHasher, ident_hash, pack_len_hash};
76#[cfg(feature = "pool")]
77pub use pool::*;
78pub use string_builder::StringBuilder;
79pub use take_in::{Dummy, TakeIn};
80pub use vec::Vec;
81
82// Fixed size allocators are only supported on 64-bit little-endian platforms at present.
83//
84// Note: Importing the `fixed_size_constants` module would cause a compilation error on 32-bit systems.
85#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))]
86mod generated {
87 #[cfg(debug_assertions)]
88 mod assert_layouts;
89 pub mod fixed_size_constants;
90}