allow wasm32 compilation of librustc_data_structures/profiling.rs
This commit is contained in:
parent
20fc02f836
commit
df3776bc0f
1 changed files with 11 additions and 4 deletions
|
|
@ -99,10 +99,12 @@ use parking_lot::RwLock;
|
|||
|
||||
/// MmapSerializatioSink is faster on macOS and Linux
|
||||
/// but FileSerializationSink is faster on Windows
|
||||
#[cfg(not(windows))]
|
||||
#[cfg(all(not(windows),not(target_arch="wasm32")))]
|
||||
type SerializationSink = measureme::MmapSerializationSink;
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows,not(target_arch="wasm32")))]
|
||||
type SerializationSink = measureme::FileSerializationSink;
|
||||
#[cfg(target_arch="wasm32")]
|
||||
type SerializationSink = measureme::ByteVecSink;
|
||||
|
||||
type Profiler = measureme::Profiler<SerializationSink>;
|
||||
|
||||
|
|
@ -602,7 +604,7 @@ pub fn duration_to_secs_str(dur: std::time::Duration) -> String {
|
|||
}
|
||||
|
||||
// Memory reporting
|
||||
#[cfg(unix)]
|
||||
#[cfg(all(unix,not(target_arch="wasm32")))]
|
||||
fn get_resident() -> Option<usize> {
|
||||
let field = 1;
|
||||
let contents = fs::read("/proc/self/statm").ok()?;
|
||||
|
|
@ -612,7 +614,7 @@ fn get_resident() -> Option<usize> {
|
|||
Some(npages * 4096)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows,not(target_arch="wasm32")))]
|
||||
fn get_resident() -> Option<usize> {
|
||||
use std::mem::{self, MaybeUninit};
|
||||
use winapi::shared::minwindef::DWORD;
|
||||
|
|
@ -630,3 +632,8 @@ fn get_resident() -> Option<usize> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch="wasm32")]
|
||||
fn get_resident() -> Option<usize> {
|
||||
None
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue