Skip to content

Commit 15e19a1

Browse files
authored
Fix length of Map64::descriptor_map (#956)
Its length should be MAX_SPACES instead of MAX_CHUNKS. The size was `MAX_SPACES` in the JikesRVM MMTk. It may have been a typo when porting JikesRVM MMTk to Rust. The new `Map64::descriptor_map` does not deserve the unsafe `new_zeroed_vec` function which was introduced to solve the slow start-up problem. We keep `new_zeroed_vec` just in case we may still need it in the future.
1 parent 42f109b commit 15e19a1

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/util/heap/layout/map64.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::util::heap::layout::vm_layout::*;
88
use crate::util::heap::space_descriptor::SpaceDescriptor;
99
use crate::util::memory::MmapStrategy;
1010
use crate::util::raw_memory_freelist::RawMemoryFreeList;
11-
use crate::util::rust_util::zeroed_alloc::new_zeroed_vec;
1211
use crate::util::Address;
1312
use std::cell::UnsafeCell;
1413
use std::ptr::NonNull;
@@ -49,16 +48,11 @@ impl Map64 {
4948
base_address[i] = base;
5049
}
5150

51+
let descriptor_map = vec![SpaceDescriptor::UNINITIALIZED; MAX_SPACES];
52+
5253
Self {
5354
inner: UnsafeCell::new(Map64Inner {
54-
// Note: descriptor_map is very large. Although it is initialized to
55-
// SpaceDescriptor(0), the compiler and the standard library are not smart enough to
56-
// elide the storing of 0 for each of the element. Using standard vector creation,
57-
// such as `vec![SpaceDescriptor::UNINITIALIZED; MAX_CHUNKS]`, will cause severe
58-
// slowdown during start-up.
59-
descriptor_map: unsafe {
60-
new_zeroed_vec::<SpaceDescriptor>(vm_layout().max_chunks())
61-
},
55+
descriptor_map,
6256
high_water,
6357
base_address,
6458
fl_page_resources: vec![None; MAX_SPACES],

src/util/rust_util/zeroed_alloc.rs

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
//! If such an allocation happens during start-up, the delay will be noticeable to light-weight
1515
//! scripting languages, such as Ruby.
1616
//!
17+
//! *(Note: We no longer allocate such large vecs at start-up. We keep this module in case we need
18+
//! to allocate large vectors in the future.)*
19+
//!
1720
//! We implement our own fast allocation of large zeroed vectors in this module. If one day Rust
1821
//! provides a standard way to optimize for zeroed allocation of vectors of composite types, we
1922
//! can switch to the standard mechanism.

0 commit comments

Comments
 (0)