Skip to content

Commit fc7f60c

Browse files
committed
fix(allocator): revert changes to get_current_chunk_footer_field_offset (#20964)
Partial revert of #18168. #18168 made a small change to `get_current_chunk_footer_field_offset` (used by `Allocator::from_raw_parts`). That change was correct in the context of the other changes made to `Bump` in that PR, but now that #20963 has rolled back most of those changes, this change needs to be reverted too as it's a potential perf regression with current version of `Bump`.
1 parent caa2dce commit fc7f60c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

crates/oxc_allocator/src/from_raw_parts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ fn get_current_chunk_footer_field_offset() -> usize {
259259
assert!(align_of::<Cell<Option<usize>>>() == align_of::<usize>());
260260
}
261261

262-
let bump = ManuallyDrop::new(Bump::new());
262+
let bump = ManuallyDrop::new(Bump::<1>::with_min_align());
263263
bump.set_allocation_limit(Some(123));
264264

265265
// SAFETY:
@@ -269,7 +269,7 @@ fn get_current_chunk_footer_field_offset() -> usize {
269269
// so either field order means 3rd `usize` is fully initialized
270270
// (it's either `NonNull<ChunkFooter>>` or the `usize` in `Option<usize>`).
271271
unsafe {
272-
let ptr = ptr::from_ref::<ManuallyDrop<Bump>>(&bump).cast::<usize>();
272+
let ptr = ptr::from_ref(&bump).cast::<usize>();
273273
if *ptr.add(2) == 123 {
274274
// `allocation_limit` is 2nd field. So `current_chunk_footer` is 1st.
275275
0

0 commit comments

Comments
 (0)