Skip to content

Commit 0f657ac

Browse files
committed
Redirect __rust_dealloc to sdallocx
1 parent 1b427b3 commit 0f657ac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/rustc/src/main.rs

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
// https://github.com/rust-lang/rust/commit/b90cfc887c31c3e7a9e6d462e2464db1fe506175#diff-43914724af6e464c1da2171e4a9b6c7e607d5bc1203fa95c0ab85be4122605ef
3535
// for an example of how to do so.
3636

37+
/// This redirects `__rust_dealloc` to jemalloc so it can make use of the size of the allocation.
38+
#[cfg(feature = "jemalloc-sys")]
39+
#[no_mangle]
40+
pub unsafe extern "C" fn __rust_dealloc(ptr: *mut u8, size: usize, _align: usize) {
41+
unsafe { jemalloc_sys::sdallocx(ptr.cast(), size, 0) }
42+
#[used]
43+
static _USED: unsafe extern "C" fn(*mut u8, usize, usize) = __rust_dealloc;
44+
}
45+
3746
#[unix_sigpipe = "sig_dfl"]
3847
fn main() {
3948
// See the comment at the top of this file for an explanation of this.

0 commit comments

Comments
 (0)