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//!
13//! See [`Allocator`] docs for information on efficient use of [`Allocator`].
14//!
15//! ## Features
16//!
17//! * `serialize` - Enables serialization support for [`Box`] and [`Vec`] with `serde` and `oxc_estree`.
18//!
19//! * `pool` - Enables [`AllocatorPool`].
20//!
21//! * `bitset` - Enables [`BitSet`].
22//!
23//! * `from_raw_parts` - Adds [`Allocator::from_raw_parts`] method.
24//! Usage of this feature is not advisable, and it will be removed as soon as we're able to.
25//!
26//! * `fixed_size` - Makes [`AllocatorPool`] create large fixed-size allocators, instead of
27//! flexibly-sized ones.
28//! Only supported on 64-bit little-endian platforms at present.
29//! Usage of this feature is not advisable, and it will be removed as soon as we're able to.
30//!
31//! * `track_allocations` - Count allocations and reallocations.
32//! For internal use only. The APIs provided by this feature are sketchy at best, and possibly
33//! undefined behavior. Do not enable this feature under any circumstances in production code.
34//!
35//! * `disable_track_allocations` - Disables `track_allocations` feature.
36//! Purpose is to prevent `--all-features` enabling allocation tracking.
37
38#![warn(missing_docs)]
39
40mod accessor;
41mod address;
42mod alloc;
43mod allocator;
44mod allocator_api2;
45#[cfg(feature = "bitset")]
46mod bitset;
47mod boxed;
48mod clone_in;
49mod convert;
50#[cfg(feature = "from_raw_parts")]
51mod from_raw_parts;
52pub mod hash_map;
53#[cfg(feature = "pool")]
54mod pool;
55mod string_builder;
56mod take_in;
57#[cfg(all(feature = "track_allocations", not(feature = "disable_track_allocations")))]
58mod tracking;
59mod vec;
60mod vec2;
61
62pub use accessor::AllocatorAccessor;
63pub use address::{Address, GetAddress};
64pub use allocator::Allocator;
65#[cfg(feature = "bitset")]
66pub use bitset::BitSet;
67pub use boxed::Box;
68pub use clone_in::CloneIn;
69pub use convert::{FromIn, IntoIn};
70pub use hash_map::HashMap;
71#[cfg(feature = "pool")]
72pub use pool::*;
73pub use string_builder::StringBuilder;
74pub use take_in::{Dummy, TakeIn};
75pub use vec::Vec;
76
77// Fixed size allocators are only supported on 64-bit little-endian platforms at present.
78//
79// Note: Importing the `fixed_size_constants` module would cause a compilation error on 32-bit systems.
80#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))]
81mod generated {
82 #[cfg(debug_assertions)]
83 mod assert_layouts;
84 pub mod fixed_size_constants;
85}