Remove size-of-struct asserts that break with some Rust versions.

The asserts on the sizes of the VCode constant-table data structures
introduced in PR #2328 are dependent on the size of data structures such
as `HashMap` in the standard library, which can change. In particular,
on Rust 1.46 (which is not current, but could be e.g. pinned by a
project using Cranelift), it appears that these asserts fail. We
shouldn't depend on stdlib internals; IMHO the asserts on our own struct
sizes are enough to catch accidental size blowups.
This commit is contained in:
Chris Fallin
2020-11-11 13:47:36 -08:00
parent 9ced345aed
commit 5e5e520654

View File

@@ -876,7 +876,7 @@ impl VCodeConstantData {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use std::mem::{size_of, size_of_val}; use std::mem::size_of;
#[test] #[test]
fn size_of_constant_structs() { fn size_of_constant_structs() {
@@ -888,11 +888,8 @@ mod test {
size_of::<PrimaryMap<VCodeConstant, VCodeConstantData>>(), size_of::<PrimaryMap<VCodeConstant, VCodeConstantData>>(),
24 24
); );
assert_eq!(size_of::<HashMap<Constant, VCodeConstant>>(), 48); // TODO The VCodeConstants structure's memory size could be further optimized.
assert_eq!(size_of::<HashMap<*const [u8], VCodeConstant>>(), 48); // With certain versions of Rust, each `HashMap` in `VCodeConstants` occupied at
assert_eq!(size_of::<VCodeConstants>(), 120); // least 48 bytes, making an empty `VCodeConstants` cost 120 bytes.
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.
} }
} }