Skip to content

Commit 0444abf

Browse files
committed
refactor(allocator/pool)!: remove disable_fixed_size Cargo feature
1 parent b71acf1 commit 0444abf

File tree

6 files changed

+9
-100
lines changed

6 files changed

+9
-100
lines changed

apps/oxlint/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ lazy-regex = { workspace = true }
6262
default = []
6363
allocator = ["dep:mimalloc-safe"]
6464
oxlint2 = ["oxc_linter/oxlint2", "oxc_allocator/fixed_size", "dep:simdutf8"]
65-
disable_oxlint2 = ["oxc_linter/disable_oxlint2", "oxc_allocator/disable_fixed_size"]
65+
disable_oxlint2 = ["oxc_linter/disable_oxlint2"]
6666
force_test_reporter = ["oxc_linter/force_test_reporter"]

crates/oxc_allocator/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ serde_json = { workspace = true }
3838
[features]
3939
bitset = []
4040
fixed_size = ["from_raw_parts", "pool", "dep:oxc_ast_macros"]
41-
disable_fixed_size = []
4241
from_raw_parts = []
4342
pool = []
4443
serialize = ["dep:serde", "oxc_estree/serialize"]

crates/oxc_allocator/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,5 @@ This approach is significantly faster than using the system allocator for AST op
3535
- `track_allocations` - Count allocations and reallocations.
3636
For internal use only. The APIs provided by this feature are sketchy at best, and possibly
3737
undefined behavior. Do not enable this feature under any circumstances in production code.
38-
- `disable_fixed_size` - Disables `fixed_size` feature.
39-
Purpose is to prevent `--all-features` enabling fixed sized allocators.
4038
- `disable_track_allocations` - Disables `track_allocations` feature.
4139
Purpose is to prevent `--all-features` enabling allocation tracking.

crates/oxc_allocator/src/lib.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
//! For internal use only. The APIs provided by this feature are sketchy at best, and possibly
3333
//! undefined behavior. Do not enable this feature under any circumstances in production code.
3434
//!
35-
//! * `disable_fixed_size` - Disables `fixed_size` feature.
36-
//! Purpose is to prevent `--all-features` enabling fixed sized allocators.
37-
//!
3835
//! * `disable_track_allocations` - Disables `track_allocations` feature.
3936
//! Purpose is to prevent `--all-features` enabling allocation tracking.
4037
@@ -80,12 +77,7 @@ pub use vec::Vec;
8077
// Fixed size allocators are only supported on 64-bit little-endian platforms at present.
8178
//
8279
// Note: Importing the `fixed_size_constants` module would cause a compilation error on 32-bit systems.
83-
#[cfg(all(
84-
feature = "fixed_size",
85-
not(feature = "disable_fixed_size"),
86-
target_pointer_width = "64",
87-
target_endian = "little"
88-
))]
80+
#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))]
8981
mod generated {
9082
#[cfg(debug_assertions)]
9183
mod assert_layouts;

crates/oxc_allocator/src/pool/mod.rs

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,16 @@ mod standard;
66
use standard::StandardAllocatorPool;
77

88
// Fixed size allocators are only supported on 64-bit little-endian platforms at present.
9-
// They are only enabled if `fixed_size` feature enabled, and `disable_fixed_size` feature is not enabled.
9+
// They are only enabled if `fixed_size` Cargo feature is enabled.
1010
//
1111
// Note: Importing the `fixed_size` module would cause a compilation error on 32-bit systems.
12-
#[cfg(all(
13-
feature = "fixed_size",
14-
not(feature = "disable_fixed_size"),
15-
target_pointer_width = "64",
16-
target_endian = "little"
17-
))]
12+
#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))]
1813
mod fixed_size;
19-
#[cfg(all(
20-
feature = "fixed_size",
21-
not(feature = "disable_fixed_size"),
22-
target_pointer_width = "64",
23-
target_endian = "little"
24-
))]
14+
#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))]
2515
use fixed_size::FixedSizeAllocatorPool;
26-
#[cfg(all(
27-
feature = "fixed_size",
28-
not(feature = "disable_fixed_size"),
29-
target_pointer_width = "64",
30-
target_endian = "little"
31-
))]
16+
#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))]
3217
pub use fixed_size::{FixedSizeAllocatorMetadata, free_fixed_size_allocator};
3318

34-
// Dummy implementations of interfaces from `fixed_size`, just to stop clippy complaining.
35-
// Seems to be necessary due to feature unification.
36-
#[cfg(not(all(
37-
feature = "fixed_size",
38-
not(feature = "disable_fixed_size"),
39-
target_pointer_width = "64",
40-
target_endian = "little"
41-
)))]
42-
pub use standard::{FixedSizeAllocatorMetadata, free_fixed_size_allocator};
43-
4419
/// A thread-safe pool for reusing [`Allocator`] instances to reduce allocation overhead.
4520
///
4621
/// Uses either:
@@ -51,20 +26,14 @@ pub use standard::{FixedSizeAllocatorMetadata, free_fixed_size_allocator};
5126
/// Fixed-size allocator pool is created by [`AllocatorPool::new_fixed_size`].
5227
///
5328
/// Fixed-size allocators are only supported on 64-bit little-endian platforms at present,
54-
/// and require the `fixed_size` Cargo feature to be enabled, and `disable_fixed_size` Cargo feature
55-
/// to not be enabled.
29+
/// and require the `fixed_size` Cargo feature to be enabled.
5630
#[repr(transparent)]
5731
pub struct AllocatorPool(AllocatorPoolInner);
5832

5933
/// Inner type of [`AllocatorPool`], holding either a standard or fixed-size allocator pool.
6034
enum AllocatorPoolInner {
6135
Standard(StandardAllocatorPool),
62-
#[cfg(all(
63-
feature = "fixed_size",
64-
not(feature = "disable_fixed_size"),
65-
target_pointer_width = "64",
66-
target_endian = "little"
67-
))]
36+
#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))]
6837
FixedSize(FixedSizeAllocatorPool),
6938
}
7039

@@ -77,7 +46,7 @@ impl AllocatorPool {
7746

7847
/// Create a new [`AllocatorPool`] for use across the specified number of threads,
7948
/// which uses fixed-size allocators (suitable for raw transfer).
80-
#[cfg(all(feature = "fixed_size", not(feature = "disable_fixed_size")))]
49+
#[cfg(feature = "fixed_size")]
8150
pub fn new_fixed_size(thread_count: usize) -> AllocatorPool {
8251
#[cfg(all(target_pointer_width = "64", target_endian = "little"))]
8352
{
@@ -102,7 +71,6 @@ impl AllocatorPool {
10271
AllocatorPoolInner::Standard(pool) => pool.get(),
10372
#[cfg(all(
10473
feature = "fixed_size",
105-
not(feature = "disable_fixed_size"),
10674
target_pointer_width = "64",
10775
target_endian = "little"
10876
))]
@@ -128,7 +96,6 @@ impl AllocatorPool {
12896
AllocatorPoolInner::Standard(pool) => pool.add(allocator),
12997
#[cfg(all(
13098
feature = "fixed_size",
131-
not(feature = "disable_fixed_size"),
13299
target_pointer_width = "64",
133100
target_endian = "little"
134101
))]

crates/oxc_allocator/src/pool/standard.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -44,50 +44,3 @@ impl StandardAllocatorPool {
4444
allocators.push(allocator);
4545
}
4646
}
47-
48-
// Dummy implementations of interfaces from `fixed_size`, just to stop clippy complaining.
49-
// Seems to be necessary due to feature unification.
50-
#[cfg(not(all(
51-
feature = "fixed_size",
52-
not(feature = "disable_fixed_size"),
53-
target_pointer_width = "64",
54-
target_endian = "little"
55-
)))]
56-
#[allow(
57-
dead_code,
58-
missing_docs,
59-
clippy::missing_safety_doc,
60-
clippy::unused_self,
61-
clippy::allow_attributes
62-
)]
63-
mod dummies {
64-
use std::{ptr::NonNull, sync::atomic::AtomicBool};
65-
66-
use crate::Allocator;
67-
68-
#[doc(hidden)]
69-
pub struct FixedSizeAllocatorMetadata {
70-
pub id: u32,
71-
pub(crate) alloc_ptr: NonNull<u8>,
72-
pub is_double_owned: AtomicBool,
73-
}
74-
75-
#[doc(hidden)]
76-
pub unsafe fn free_fixed_size_allocator(_metadata_ptr: NonNull<FixedSizeAllocatorMetadata>) {
77-
unreachable!();
78-
}
79-
80-
#[doc(hidden)]
81-
impl Allocator {
82-
pub unsafe fn fixed_size_metadata_ptr(&self) -> NonNull<FixedSizeAllocatorMetadata> {
83-
unreachable!();
84-
}
85-
}
86-
}
87-
#[cfg(not(all(
88-
feature = "fixed_size",
89-
not(feature = "disable_fixed_size"),
90-
target_pointer_width = "64",
91-
target_endian = "little"
92-
)))]
93-
pub use dummies::*;

0 commit comments

Comments
 (0)