Replace MaybeUninit in allocator arrays with Option#1483
Replace MaybeUninit in allocator arrays with Option#1483caizixian wants to merge 4 commits intommtk:masterfrom
Conversation
|
Not sure if it is easy to test, but if it is not performance critical, we may just use |
|
|
|
Option is not technically FFI safe either though |
b9bf027 to
57b5f48
Compare
|
Right. |
|
Does The other option to remove |
|
This test could check the layout and ffi compatibility: // GITHUB-CI: MMTK_PLAN=NoGC
// Just test this onece.
use lazy_static::lazy_static;
use super::mock_test_prelude::*;
use crate::util::alloc::*;
use std::mem::size_of;
#[test]
pub fn test_option_allocator_layout() {
assert_eq!(size_of::<Option<BumpAllocator<MockVM>>>(), size_of::<BumpAllocator<MockVM>>());
assert_eq!(size_of::<Option<LargeObjectAllocator<MockVM>>>(), size_of::<LargeObjectAllocator<MockVM>>());
assert_eq!(size_of::<Option<MallocAllocator<MockVM>>>(), size_of::<MallocAllocator<MockVM>>());
assert_eq!(size_of::<Option<ImmixAllocator<MockVM>>>(), size_of::<ImmixAllocator<MockVM>>());
assert_eq!(size_of::<Option<FreeListAllocator<MockVM>>>(), size_of::<FreeListAllocator<MockVM>>());
assert_eq!(size_of::<Option<MarkCompactAllocator<MockVM>>>(), size_of::<MarkCompactAllocator<MockVM>>());
}
#[test]
pub fn test_0_transmute_as_option_none() {
const BUMP_ALLOCATOR_SIZE: usize = size_of::<Option<BumpAllocator<MockVM>>>();
let zero_bump = unsafe { std::mem::transmute::<_, Option<BumpAllocator<MockVM>>>([0u8; BUMP_ALLOCATOR_SIZE]) };
assert!(zero_bump.is_none());
} |
|
Can you check the performance of this PR? @caizixian |
fa812b2 to
cba54c6
Compare
|
Unit tests added and checked with |
cba54c6 to
5d9e8b1
Compare
I don't think the changes here are performance sensitive but I can run some benchmarks if needed