diff --git a/Cargo.lock b/Cargo.lock index daf29de155..390fd7e8f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2670,26 +2670,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scroll" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "semver" version = "1.0.3" @@ -3785,7 +3765,6 @@ dependencies = [ "more-asserts", "object", "region", - "scroll", "serde", "target-lexicon", "thiserror", diff --git a/crates/jit/Cargo.toml b/crates/jit/Cargo.toml index ac26e7404b..139d19e9cf 100644 --- a/crates/jit/Cargo.toml +++ b/crates/jit/Cargo.toml @@ -26,7 +26,6 @@ object = { version = "0.26.0", default-features = false, features = ["std", "rea serde = { version = "1.0.94", features = ["derive"] } addr2line = { version = "0.16.0", default-features = false } libc = { version = "0.2.60", default-features = false, optional = true } -scroll = { version = "0.10.1", features = ["derive"], optional = true } ittapi-rs = { version = "0.1.5", optional = true } bincode = "1.2.1" @@ -34,7 +33,7 @@ bincode = "1.2.1" winapi = { version = "0.3.8", features = ["winnt", "impl-default"] } [features] -jitdump = ['libc', 'scroll'] +jitdump = ['libc'] vtune = ['ittapi-rs'] [badges] diff --git a/crates/jit/src/profiling/jitdump_linux.rs b/crates/jit/src/profiling/jitdump_linux.rs index 1971345123..b794e29d9c 100644 --- a/crates/jit/src/profiling/jitdump_linux.rs +++ b/crates/jit/src/profiling/jitdump_linux.rs @@ -14,8 +14,6 @@ use crate::{CompiledModule, ProfilingAgent}; use anyhow::Result; use object::{Object, ObjectSection}; -use scroll::{IOwrite, SizeWith, NATIVE}; -use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::fs::{File, OpenOptions}; use std::io; @@ -44,7 +42,7 @@ pub enum RecordId { } /// Each record starts with this fixed size record header which describes the record that follows -#[derive(Serialize, Deserialize, Debug, Default, Clone, Copy, IOwrite, SizeWith)] +#[derive(Debug, Default, Clone, Copy)] #[repr(C)] pub struct RecordHeader { /// uint32_t id: a value identifying the record type (see below) @@ -55,8 +53,10 @@ pub struct RecordHeader { timestamp: u64, } +unsafe impl object::Pod for RecordHeader {} + /// The CodeLoadRecord is used for describing jitted functions -#[derive(Serialize, Deserialize, Debug, Default, Clone, Copy, IOwrite, SizeWith)] +#[derive(Debug, Default, Clone, Copy)] #[repr(C)] pub struct CodeLoadRecord { /// Fixed sized header that describes this record @@ -75,8 +75,10 @@ pub struct CodeLoadRecord { index: u64, } +unsafe impl object::Pod for CodeLoadRecord {} + /// Describes source line information for a jitted function -#[derive(Serialize, Deserialize, Debug, Default)] +#[derive(Debug, Default)] #[repr(C)] pub struct DebugEntry { /// uint64_t code_addr: address of function for which the debug information is generated @@ -92,7 +94,7 @@ pub struct DebugEntry { /// Describes debug information for a jitted function. An array of debug entries are /// appended to this record during writting. Note, this record must preceed the code /// load record that describes the same jitted function. -#[derive(Serialize, Deserialize, Debug, Default, Clone, Copy, IOwrite, SizeWith)] +#[derive(Debug, Default, Clone, Copy)] #[repr(C)] pub struct DebugInfoRecord { /// Fixed sized header that describes this record @@ -103,8 +105,10 @@ pub struct DebugInfoRecord { count: u64, } +unsafe impl object::Pod for DebugInfoRecord {} + /// Fixed-sized header for each jitdump file -#[derive(Serialize, Deserialize, Debug, Default, IOwrite, SizeWith)] +#[derive(Debug, Default, Clone, Copy)] #[repr(C)] pub struct FileHeader { /// uint32_t magic: a magic number tagging the file type. The value is 4-byte long and represents the @@ -127,6 +131,8 @@ pub struct FileHeader { flags: u64, } +unsafe impl object::Pod for FileHeader {} + /// Interface for driving the creation of jitdump files pub struct JitDumpAgent { // Note that we use a mutex internally to serialize writing out to our @@ -246,7 +252,7 @@ impl State { flags: 0, }; - self.jitdump_file.iowrite_with(header, NATIVE)?; + self.jitdump_file.write_all(object::bytes_of(&header))?; Ok(()) } @@ -256,7 +262,7 @@ impl State { cl_record: CodeLoadRecord, code_buffer: &[u8], ) -> Result<()> { - self.jitdump_file.iowrite_with(cl_record, NATIVE)?; + self.jitdump_file.write_all(object::bytes_of(&cl_record))?; self.jitdump_file.write_all(record_name.as_bytes())?; self.jitdump_file.write_all(b"\0")?; self.jitdump_file.write_all(code_buffer)?; @@ -266,7 +272,7 @@ impl State { /// Write DebugInfoRecord to open jit dump file. /// Must be written before the corresponding CodeLoadRecord. fn write_debug_info_record(&mut self, dir_record: DebugInfoRecord) -> Result<()> { - self.jitdump_file.iowrite_with(dir_record, NATIVE)?; + self.jitdump_file.write_all(object::bytes_of(&dir_record))?; Ok(()) } @@ -274,10 +280,11 @@ impl State { /// Must be written before the corresponding CodeLoadRecord. fn write_debug_info_entries(&mut self, die_entries: Vec) -> Result<()> { for entry in die_entries.iter() { - self.jitdump_file.iowrite_with(entry.address, NATIVE)?; - self.jitdump_file.iowrite_with(entry.line, NATIVE)?; self.jitdump_file - .iowrite_with(entry.discriminator, NATIVE)?; + .write_all(object::bytes_of(&entry.address))?; + self.jitdump_file.write_all(object::bytes_of(&entry.line))?; + self.jitdump_file + .write_all(object::bytes_of(&entry.discriminator))?; self.jitdump_file.write_all(entry.filename.as_bytes())?; self.jitdump_file.write_all(b"\0")?; }