Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix length of Map64::descriptor_map #956

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/util/heap/layout/map64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::util::heap::layout::vm_layout::*;
use crate::util::heap::space_descriptor::SpaceDescriptor;
use crate::util::memory::MmapStrategy;
use crate::util::raw_memory_freelist::RawMemoryFreeList;
use crate::util::rust_util::zeroed_alloc::new_zeroed_vec;
use crate::util::Address;
use std::cell::UnsafeCell;
use std::ptr::NonNull;
Expand Down Expand Up @@ -49,16 +48,11 @@ impl Map64 {
base_address[i] = base;
}

let descriptor_map = vec![SpaceDescriptor::UNINITIALIZED; MAX_SPACES];

Self {
inner: UnsafeCell::new(Map64Inner {
// Note: descriptor_map is very large. Although it is initialized to
// SpaceDescriptor(0), the compiler and the standard library are not smart enough to
// elide the storing of 0 for each of the element. Using standard vector creation,
// such as `vec![SpaceDescriptor::UNINITIALIZED; MAX_CHUNKS]`, will cause severe
// slowdown during start-up.
descriptor_map: unsafe {
new_zeroed_vec::<SpaceDescriptor>(vm_layout().max_chunks())
},
descriptor_map,
high_water,
base_address,
fl_page_resources: vec![None; MAX_SPACES],
Expand Down
3 changes: 3 additions & 0 deletions src/util/rust_util/zeroed_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
//! If such an allocation happens during start-up, the delay will be noticeable to light-weight
//! scripting languages, such as Ruby.
//!
//! *(Note: We no longer allocate such large vecs at start-up. We keep this module in case we need
//! to allocate large vectors in the future.)*
//!
//! We implement our own fast allocation of large zeroed vectors in this module. If one day Rust
//! provides a standard way to optimize for zeroed allocation of vectors of composite types, we
//! can switch to the standard mechanism.
Expand Down
Loading