swc_malloc/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! This crate configures memory allocator.
//!
//! The swc crates related to the  node binding should depend on this crate.

#[cfg(any(
    not(any(
        target_os = "linux",
        target_family = "wasm",
        target_env = "musl",
        all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm"))
    )),
    all(
        target_os = "linux",
        not(any(
            target_family = "wasm",
            target_env = "musl",
            all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm"))
        ))
    )
))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

// On linux aarch64, mimalloc fails to build.
// So we use tikv-jemallocator instead.

#[cfg(all(
    target_os = "linux",
    target_env = "gnu",
    any(target_arch = "aarch64", target_arch = "arm")
))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;