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
39#![warn(missing_docs)]
40
41mod accessor;
42mod address;
43mod alloc;
44mod allocator;
45mod allocator_api2;
46#[cfg(feature = "bitset")]
47mod bitset;
48mod boxed;
49mod clone_in;
50mod convert;
51#[cfg(feature = "from_raw_parts")]
52mod from_raw_parts;
53pub mod hash_map;
54pub mod hash_set;
55#[cfg(feature = "pool")]
56mod pool;
57mod string_builder;
58mod take_in;
59#[cfg(all(feature = "track_allocations", not(feature = "disable_track_allocations")))]
60mod tracking;
61mod vec;
62mod vec2;
63
64pub use accessor::AllocatorAccessor;
65pub use address::{Address, GetAddress};
66pub use allocator::Allocator;
67#[cfg(feature = "bitset")]
68pub use bitset::BitSet;
69pub use boxed::Box;
70pub use clone_in::CloneIn;
71pub use convert::{FromIn, IntoIn};
72pub use hash_map::HashMap;
73pub use hash_set::HashSet;
74#[cfg(feature = "pool")]
75pub use pool::*;
76pub use string_builder::StringBuilder;
77pub use take_in::{Dummy, TakeIn};
78pub use vec::Vec;
79
80// Fixed size allocators are only supported on 64-bit little-endian platforms at present.
81//
82// Note: Importing the `fixed_size_constants` module would cause a compilation error on 32-bit systems.
83#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))]
84mod generated {
85 #[cfg(debug_assertions)]
86 mod assert_layouts;
87 pub mod fixed_size_constants;
88}