Skip to content

Commit

Permalink
Fix compiler errors and warnings for Rust 1.78.0 (#1132)
Browse files Browse the repository at this point in the history
`ScanObjectsWork::make_another` is unused. It was used when
`ScanObjectsWork` was used for scanning node roots. Now that node roots
are scanned by the dedicated `ProcessRootNode` work packet, we can
remove it.

`WorkCounter::get_base_mut` is never used. All derived counters use
`merge_val` to update all fields at the same time.

We use `Box::as_ref()` to get the reference to its underlying element.
It fixes a compilation error related to CommonFreeListPageResource. But
we should eventually remove CommonFreeListPageResource completely as it
is a workaround for mimicking the legacy design from JikesRVM that allow
VMMap to enumerate and patch existing FreeListPageResource instances by
registering them in a global list, which is not idiomatic in Rust. See
#934 and
#953.
  • Loading branch information
wks authored May 6, 2024
1 parent fea59e4 commit 5f955bc
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/policy/sft_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ mod dense_chunk_map {

let space_name = unsafe { &*space }.name().to_string();
// We shouldn't have this space in our map yet. Otherwise, this method is called multiple times for the same space.
assert!(self.index_map.get(&space_name).is_none());
assert!(!self.index_map.contains_key(&space_name));
// Index for the space
let index = self.sft.len();
// Insert to hashmap and vec
Expand Down
13 changes: 1 addition & 12 deletions src/scheduler/gc_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,7 @@ pub trait ScanObjectsWork<VM: VMBinding>: GCWork<VM> + Sized {
/// Called after each object is scanned.
fn post_scan_object(&self, object: ObjectReference);

/// Create another object-scanning work packet of the same kind, to scan adjacent objects of
/// the objects in this packet.
fn make_another(&self, buffer: Vec<ObjectReference>) -> Self;

/// Return the work bucket for this work packet and its derived work packets.
fn get_bucket(&self) -> WorkBucketStage;

/// The common code for ScanObjects and PlanScanObjects.
Expand Down Expand Up @@ -869,10 +866,6 @@ impl<VM: VMBinding, E: ProcessEdgesWork<VM = VM>> ScanObjectsWork<VM> for ScanOb
fn post_scan_object(&self, _object: ObjectReference) {
// Do nothing.
}

fn make_another(&self, buffer: Vec<ObjectReference>) -> Self {
Self::new(buffer, self.concurrent, self.bucket)
}
}

impl<E: ProcessEdgesWork> GCWork<E::VM> for ScanObjects<E> {
Expand Down Expand Up @@ -997,10 +990,6 @@ impl<E: ProcessEdgesWork, P: Plan<VM = E::VM> + PlanTraceObject<E::VM>> ScanObje
fn post_scan_object(&self, object: ObjectReference) {
self.plan.post_scan_object(object);
}

fn make_another(&self, buffer: Vec<ObjectReference>) -> Self {
Self::new(self.plan, buffer, self.concurrent, self.bucket)
}
}

impl<E: ProcessEdgesWork, P: Plan<VM = E::VM> + PlanTraceObject<E::VM>> GCWork<E::VM>
Expand Down
9 changes: 0 additions & 9 deletions src/scheduler/work_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ pub(super) trait WorkCounter: WorkCounterClone + std::fmt::Debug + Send {
fn name(&self) -> String;
/// Return a reference to [`WorkCounterBase`]
fn get_base(&self) -> &WorkCounterBase;
/// Return a mutatable reference to [`WorkCounterBase`]
fn get_base_mut(&mut self) -> &mut WorkCounterBase;
}

impl Clone for Box<dyn WorkCounter> {
Expand Down Expand Up @@ -128,10 +126,6 @@ impl WorkCounter for WorkDuration {
fn get_base(&self) -> &WorkCounterBase {
&self.base
}

fn get_base_mut(&mut self) -> &mut WorkCounterBase {
&mut self.base
}
}

#[cfg(feature = "perf_counter")]
Expand Down Expand Up @@ -207,9 +201,6 @@ mod perf_event {
fn get_base(&self) -> &WorkCounterBase {
&self.base
}
fn get_base_mut(&mut self) -> &mut WorkCounterBase {
&mut self.base
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/heap/freelistpageresource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl<VM: VMBinding> FreeListPageResource<VM> {
// Since `Space` instances are always stored as global variables, so it is okay here
// to turn `&CommonFreeListPageResource` into `&'static CommonFreeListPageResource`
unsafe {
vm_map.bind_freelist(&*(&common_flpr as &CommonFreeListPageResource as *const _));
vm_map.bind_freelist(common_flpr.as_ref() as *const _);
}
common_flpr
};
Expand Down Expand Up @@ -220,7 +220,7 @@ impl<VM: VMBinding> FreeListPageResource<VM> {
// Since `Space` instances are always stored as global variables, so it is okay here
// to turn `&CommonFreeListPageResource` into `&'static CommonFreeListPageResource`
unsafe {
vm_map.bind_freelist(&*(&common_flpr as &CommonFreeListPageResource as *const _));
vm_map.bind_freelist(common_flpr.as_ref() as *const _);
}
common_flpr
};
Expand Down
4 changes: 2 additions & 2 deletions src/vm/tests/mock_tests/mock_test_malloc_counted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn realloc_grow() {
MMTK.with_fixture(|fixture| {
let bytes_before = memory_manager::get_malloc_bytes(fixture.get_mmtk());

let res1 = memory_manager::counted_malloc(&fixture.get_mmtk(), 8);
let res1 = memory_manager::counted_malloc(fixture.get_mmtk(), 8);
assert!(!res1.is_zero());
let bytes_after_alloc = memory_manager::get_malloc_bytes(fixture.get_mmtk());
assert_eq!(bytes_before + 8, bytes_after_alloc);
Expand All @@ -69,7 +69,7 @@ pub fn realloc_grow() {
let bytes_after_realloc = memory_manager::get_malloc_bytes(fixture.get_mmtk());
assert_eq!(bytes_before + 16, bytes_after_realloc);

memory_manager::free_with_size(&fixture.get_mmtk(), res2, 16);
memory_manager::free_with_size(fixture.get_mmtk(), res2, 16);
let bytes_after_free = memory_manager::get_malloc_bytes(fixture.get_mmtk());
assert_eq!(bytes_before, bytes_after_free);
});
Expand Down
2 changes: 0 additions & 2 deletions src/vm/tests/mock_tests/mock_test_mmtk_julia_pr_143.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// It tries to set a certain range as VM space. The range does not conflict with the virtual
// address range we use for spaces. We cannot use SFTSpaceMap as the SFT map implementation.

use lazy_static::lazy_static;

use super::mock_test_prelude::*;
use crate::memory_manager;
use crate::util::Address;
Expand Down

0 comments on commit 5f955bc

Please sign in to comment.