Commit Graph

18 Commits

Author SHA1 Message Date
Boshen 2cde1f6671 fix(rust): address nightly deprecations (#25998)
Addresses deprecations reported by the latest Rust nightly while preserving Rust 1.98 compatibility.

- Rename `unit-bindings` to `unit_bindings`: hyphenated lint names are deprecated in favor of their canonical underscore spelling.
- Replace `isize::max_value()` and `usize::max_value()` with `isize::MAX` and `usize::MAX`: the legacy numeric methods are deprecated in favor of associated constants.
- Set explicit `MAX_INDEX` values on `define_index_type!`: `oxc_index` otherwise generates `<raw>::max_value() as usize`; the explicit modern constants avoid that deprecated expansion without changing the index limits.
- Remove obsolete `clippy::legacy_numeric_constants` expectations: the corrected code no longer triggers that lint, so the expectations would be unfulfilled.
- Allow the AST scanner to consume optional `define_index_type!` configuration: it previously parsed only the struct declaration and rejected the added `MAX_INDEX` option.

AI-assisted.
2026-08-22 11:34:02 +00:00
overlookmotel 10fd38eab4 test(allocator, data_structures, str): use implements! macro in tests (#24722)
Use `implements!` macro (introduced in #24721) in various tests, including adding some new ones.

The most valuable change is replacing a `compile_fail` doctest which checks that `Arena` is not `Sync`. Using `assert!(implements!(Arena: !Sync));` is more robust.
2026-07-20 12:36:14 +00:00
overlookmotel 94a41eb032 refactor(allocator): clarify max calculations in Arena (#21796)
Small refactor to `Arena`. Use `cmp::max(a, b)` instead of the chained version `a.max(b)`. I find the former clearer.

Also simplify one `max` operation (see comment in code).
2026-04-26 21:45:46 +00:00
overlookmotel 7896bd086c perf(allocator): Allocator::used_bytes do not use chunk iterator (#21771)
Add a method `Arena::used_bytes` which `Allocator::used_bytes` utilizes. Re-implement it to avoid using `ChunkRawIter` iterator, which is slightly more performant.
2026-04-26 21:45:42 +00:00
overlookmotel 82aad73bf2 test(allocator): reformat comments (#21747)
Just reformat some comments to make them take up less lines.
2026-04-26 21:45:41 +00:00
overlookmotel 8fd3746560 refactor(allocator): ChunkRawIter yield NonNull pointers (#21738)
`ChunkRawIter` is an iterator over pointer & length pairs for an `Arena`'s chunks. Alter it to return `NonNull<u8>` pointers instead of `*mut u8` pointers.

This is not a breaking change, as we do not expose the `Arena` type externally.
2026-04-25 11:22:39 +00:00
overlookmotel 7fc032a3bb refactor(allocator): simplify Arena creation methods (#21720)
Refactor `Arena` creation methods to simplify and clarify them:

- All `Arena<1>` methods delegate directly to the corresponding generic `Arena<MIN_ALIGN>` methods.
- Remove `Arena::try_new`. It's pointless as it always returns `Ok`, so is equivalent to `Arena::new`.
- Add `#[inline]` to small methods, and ones which purely delegate to another method.
2026-04-24 17:10:08 +00:00
overlookmotel 20100549e8 test(allocator): reformat imports (#21701)
Style change only. Collapse imports from `std` into a single `use` statement, and re-order `use` statements in tests for `Arena`.
2026-04-24 12:23:02 +00:00
overlookmotel 7462c4a5ee test(allocator): fix Bump test on 32-bit platforms (#21309)
Fix a test for `Bump` which was failing on 32-bit in CI.

#21291 temporarily disabled the test. Turn out, there's no easy way to make this test work on 32-bit platforms, and #21510 added ample unit tests which effectively test the same thing.

So keep it disabled on 32-bit, but fix the test to make it work properly on 64-bit.

Rationale for the fix is explained in https://github.com/fitzgen/bumpalo/pull/320.
2026-04-24 12:23:01 +00:00
overlookmotel b152c9f685 refactor(allocator): remove Arena::allocated_bytes_including_metadata method (#21443)
Remove this method. It's not useful.
2026-04-14 21:56:05 +00:00
overlookmotel 9bd0994781 refactor(allocator): remove allocation limit in Arena (#21442)
`Arena` had a feature which allowed setting an upper bound on the size of an allocator. This complicates the implementation and is not useful for our purposes (how would we gracefully handle running out of memory during parsing anyway?). So remove it.

`Arena::from_raw_parts` (used by raw transfer) does need a way to prevent an allocator growing beyond it's initial size (2 GiB), but we can provide that with a simpler method - just a `bool` which indicates if the arena can create new chunks or not.
2026-04-14 21:56:05 +00:00
overlookmotel 3fa065e721 refactor(allocator): remove Arena::alloc_slice_try_fill_with method (#21440)
These methods are not useful. Remove them.
2026-04-14 21:56:04 +00:00
overlookmotel a656195f52 refactor(allocator): remove Arena::alloc_slice_try_fill_iter method (#21439)
These methods are not useful. Remove them.
2026-04-14 21:56:04 +00:00
overlookmotel b407d01cdc refactor(allocator): remove Arena::alloc_try_with and try_alloc_try_with methods (#21438)
These methods are not useful. Remove them.
2026-04-14 21:56:04 +00:00
overlookmotel 80ba06d9a2 refactor(allocator): rename bump module to arena (#21396)
Pure refactor. Rename `bump.rs` to `arena.rs`, and rename `bump` tests directory to `arena` - in line with renaming `Bump` to `Arena` (#21394).

No substantive changes, only renaming.
2026-04-13 18:32:56 +00:00
overlookmotel f9c4f29d59 refactor(allocator): rename Bump to Arena (#21394)
Pure refactor. Rename `Bump` to `Arena`. The name "Bump" was a legacy from `bumpalo`, `Arena` is a more appropriate name.

No substantive changes, only renaming.
2026-04-13 18:32:55 +00:00
overlookmotel bdac624083 test(allocator): skip failing test on 32-bit platforms (#21291)
This test is consistently failing on 32-bit CI.

e.g. https://github.com/oxc-project/oxc/actions/runs/24210394836/job/70677275438

I don't understand the logic of this test. At first glance it looks like the test is flawed, and it's only passing on 64-bit for incidental reasons - due to the memory regions that allocators tend to use.

I'll investigate further, but in meantime just skip the test on 32-bit to make CI green again.
2026-04-10 03:07:02 +00:00
overlookmotel e00555726b test(allocator): copy Bump tests from bumpalo (#21270)
#20963 copied `bumpalo`'s code into `oxc_allocator` crate, but I
neglected to copy across the tests.

This PR copies all `bumpalo`'s test files that relate to `Bump`, and
makes only in the minimum required changes to make them compile and the
tests pass.

2 tests required modification to pass:

1. `change_allocation_limit_with_live_allocations`
2. `reset_updates_allocated_bytes`

Both failed because oxc's `Bump` uses a 16 KiB default chunk size (vs
`bumpalo`'s 512 bytes). The fix is to create the `Bump` with
`with_capacity(448)` / `with_capacity(512)` respectively, so the initial
chunk is small enough for the test logic to work as intended (limit not
already exceeded, and two allocations spanning multiple chunks).

That apart, the tests are unaltered except for import paths and other
cosmetic changes, the changes that are made are split into multiple
small commits for ease of review. I'm going to manually merge this PR,
so that we have a "paper trail" of what changes were made to the tests
in GitHub (not merging with Graphite which would squash all the
commits).
2026-04-09 20:56:19 +01:00