Skip to content

Commit

Permalink
Merge pull request #2394 from cfallin/no-size-asserts
Browse files Browse the repository at this point in the history
Remove size-of-struct asserts that break with some Rust versions.
  • Loading branch information
cfallin authored Nov 12, 2020
2 parents 997b654 + 5e5e520 commit 1964036
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cranelift/codegen/src/machinst/vcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ impl VCodeConstantData {
#[cfg(test)]
mod test {
use super::*;
use std::mem::{size_of, size_of_val};
use std::mem::size_of;

#[test]
fn size_of_constant_structs() {
Expand All @@ -888,11 +888,8 @@ mod test {
size_of::<PrimaryMap<VCodeConstant, VCodeConstantData>>(),
24
);
assert_eq!(size_of::<HashMap<Constant, VCodeConstant>>(), 48);
assert_eq!(size_of::<HashMap<*const [u8], VCodeConstant>>(), 48);
assert_eq!(size_of::<VCodeConstants>(), 120);
assert_eq!(size_of_val(&VCodeConstants::with_capacity(0)), 120);
// TODO This structure could use some significant memory-size optimization. The use of
// HashMap to deduplicate both pool and well-known constants is clearly an issue.
// TODO The VCodeConstants structure's memory size could be further optimized.
// With certain versions of Rust, each `HashMap` in `VCodeConstants` occupied at
// least 48 bytes, making an empty `VCodeConstants` cost 120 bytes.
}
}

0 comments on commit 1964036

Please sign in to comment.