Skip to content

Commit 5f955bc

Browse files
authored
Fix compiler errors and warnings for Rust 1.78.0 (#1132)
`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.
1 parent fea59e4 commit 5f955bc

File tree

6 files changed

+6
-28
lines changed

6 files changed

+6
-28
lines changed

src/policy/sft_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ mod dense_chunk_map {
361361

362362
let space_name = unsafe { &*space }.name().to_string();
363363
// We shouldn't have this space in our map yet. Otherwise, this method is called multiple times for the same space.
364-
assert!(self.index_map.get(&space_name).is_none());
364+
assert!(!self.index_map.contains_key(&space_name));
365365
// Index for the space
366366
let index = self.sft.len();
367367
// Insert to hashmap and vec

src/scheduler/gc_work.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,7 @@ pub trait ScanObjectsWork<VM: VMBinding>: GCWork<VM> + Sized {
763763
/// Called after each object is scanned.
764764
fn post_scan_object(&self, object: ObjectReference);
765765

766-
/// Create another object-scanning work packet of the same kind, to scan adjacent objects of
767-
/// the objects in this packet.
768-
fn make_another(&self, buffer: Vec<ObjectReference>) -> Self;
769-
766+
/// Return the work bucket for this work packet and its derived work packets.
770767
fn get_bucket(&self) -> WorkBucketStage;
771768

772769
/// The common code for ScanObjects and PlanScanObjects.
@@ -869,10 +866,6 @@ impl<VM: VMBinding, E: ProcessEdgesWork<VM = VM>> ScanObjectsWork<VM> for ScanOb
869866
fn post_scan_object(&self, _object: ObjectReference) {
870867
// Do nothing.
871868
}
872-
873-
fn make_another(&self, buffer: Vec<ObjectReference>) -> Self {
874-
Self::new(buffer, self.concurrent, self.bucket)
875-
}
876869
}
877870

878871
impl<E: ProcessEdgesWork> GCWork<E::VM> for ScanObjects<E> {
@@ -997,10 +990,6 @@ impl<E: ProcessEdgesWork, P: Plan<VM = E::VM> + PlanTraceObject<E::VM>> ScanObje
997990
fn post_scan_object(&self, object: ObjectReference) {
998991
self.plan.post_scan_object(object);
999992
}
1000-
1001-
fn make_another(&self, buffer: Vec<ObjectReference>) -> Self {
1002-
Self::new(self.plan, buffer, self.concurrent, self.bucket)
1003-
}
1004993
}
1005994

1006995
impl<E: ProcessEdgesWork, P: Plan<VM = E::VM> + PlanTraceObject<E::VM>> GCWork<E::VM>

src/scheduler/work_counter.rs

-9
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ pub(super) trait WorkCounter: WorkCounterClone + std::fmt::Debug + Send {
4444
fn name(&self) -> String;
4545
/// Return a reference to [`WorkCounterBase`]
4646
fn get_base(&self) -> &WorkCounterBase;
47-
/// Return a mutatable reference to [`WorkCounterBase`]
48-
fn get_base_mut(&mut self) -> &mut WorkCounterBase;
4947
}
5048

5149
impl Clone for Box<dyn WorkCounter> {
@@ -128,10 +126,6 @@ impl WorkCounter for WorkDuration {
128126
fn get_base(&self) -> &WorkCounterBase {
129127
&self.base
130128
}
131-
132-
fn get_base_mut(&mut self) -> &mut WorkCounterBase {
133-
&mut self.base
134-
}
135129
}
136130

137131
#[cfg(feature = "perf_counter")]
@@ -207,9 +201,6 @@ mod perf_event {
207201
fn get_base(&self) -> &WorkCounterBase {
208202
&self.base
209203
}
210-
fn get_base_mut(&mut self) -> &mut WorkCounterBase {
211-
&mut self.base
212-
}
213204
}
214205
}
215206

src/util/heap/freelistpageresource.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<VM: VMBinding> FreeListPageResource<VM> {
190190
// Since `Space` instances are always stored as global variables, so it is okay here
191191
// to turn `&CommonFreeListPageResource` into `&'static CommonFreeListPageResource`
192192
unsafe {
193-
vm_map.bind_freelist(&*(&common_flpr as &CommonFreeListPageResource as *const _));
193+
vm_map.bind_freelist(common_flpr.as_ref() as *const _);
194194
}
195195
common_flpr
196196
};
@@ -220,7 +220,7 @@ impl<VM: VMBinding> FreeListPageResource<VM> {
220220
// Since `Space` instances are always stored as global variables, so it is okay here
221221
// to turn `&CommonFreeListPageResource` into `&'static CommonFreeListPageResource`
222222
unsafe {
223-
vm_map.bind_freelist(&*(&common_flpr as &CommonFreeListPageResource as *const _));
223+
vm_map.bind_freelist(common_flpr.as_ref() as *const _);
224224
}
225225
common_flpr
226226
};

src/vm/tests/mock_tests/mock_test_malloc_counted.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub fn realloc_grow() {
5858
MMTK.with_fixture(|fixture| {
5959
let bytes_before = memory_manager::get_malloc_bytes(fixture.get_mmtk());
6060

61-
let res1 = memory_manager::counted_malloc(&fixture.get_mmtk(), 8);
61+
let res1 = memory_manager::counted_malloc(fixture.get_mmtk(), 8);
6262
assert!(!res1.is_zero());
6363
let bytes_after_alloc = memory_manager::get_malloc_bytes(fixture.get_mmtk());
6464
assert_eq!(bytes_before + 8, bytes_after_alloc);
@@ -69,7 +69,7 @@ pub fn realloc_grow() {
6969
let bytes_after_realloc = memory_manager::get_malloc_bytes(fixture.get_mmtk());
7070
assert_eq!(bytes_before + 16, bytes_after_realloc);
7171

72-
memory_manager::free_with_size(&fixture.get_mmtk(), res2, 16);
72+
memory_manager::free_with_size(fixture.get_mmtk(), res2, 16);
7373
let bytes_after_free = memory_manager::get_malloc_bytes(fixture.get_mmtk());
7474
assert_eq!(bytes_before, bytes_after_free);
7575
});

src/vm/tests/mock_tests/mock_test_mmtk_julia_pr_143.rs

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// It tries to set a certain range as VM space. The range does not conflict with the virtual
66
// address range we use for spaces. We cannot use SFTSpaceMap as the SFT map implementation.
77

8-
use lazy_static::lazy_static;
9-
108
use super::mock_test_prelude::*;
119
use crate::memory_manager;
1210
use crate::util::Address;

0 commit comments

Comments
 (0)