Skip to content

Commit 0ac9484

Browse files
authored
Merge pull request #21 from wks/tidy-up-mutator-scan-api
Fix for an upstream API change.
2 parents f1a05c6 + 392955f commit 0ac9484

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

mmtk/src/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ pub struct RubyUpcalls {
342342
data: *mut libc::c_void,
343343
),
344344
pub scan_vm_specific_roots: extern "C" fn(),
345-
pub scan_thread_roots: extern "C" fn(),
346-
pub scan_thread_root: extern "C" fn(mutator_tls: VMMutatorThread, worker_tls: VMWorkerThread),
345+
pub scan_roots_in_mutator_thread:
346+
extern "C" fn(mutator_tls: VMMutatorThread, worker_tls: VMWorkerThread),
347347
pub scan_object_ruby_style: extern "C" fn(object: ObjectReference),
348348
pub call_gc_mark_children: extern "C" fn(object: ObjectReference),
349349
pub call_obj_free: extern "C" fn(object: ObjectReference),

mmtk/src/collection.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
use crate::abi::GCThreadTLS;
22

3+
use crate::api::RubyMutator;
34
use crate::{mmtk, upcalls, Ruby};
5+
use mmtk::memory_manager;
46
use mmtk::scheduler::*;
57
use mmtk::util::{VMMutatorThread, VMThread, VMWorkerThread};
68
use mmtk::vm::{Collection, GCThreadContext};
7-
use mmtk::{memory_manager, MutatorContext};
89
use std::thread;
910

1011
pub struct VMCollection {}
1112

1213
impl Collection<Ruby> for VMCollection {
13-
fn stop_all_mutators<F>(tls: VMWorkerThread, _mutator_visitor: F)
14+
fn stop_all_mutators<F>(tls: VMWorkerThread, mut mutator_visitor: F)
1415
where
1516
F: FnMut(&'static mut mmtk::Mutator<Ruby>),
1617
{
1718
(upcalls().stop_the_world)(tls);
1819
crate::binding().ppp_registry.pin_ppp_children(tls);
20+
(upcalls().get_mutators)(
21+
Self::notify_mutator_ready::<F>,
22+
&mut mutator_visitor as *mut F as *mut _,
23+
);
1924
}
2025

2126
fn resume_mutators(tls: VMWorkerThread) {
@@ -77,15 +82,18 @@ impl Collection<Ruby> for VMCollection {
7782
}
7883
}
7984

80-
fn prepare_mutator<T: MutatorContext<Ruby>>(
81-
_tls_worker: VMWorkerThread,
82-
_tls_mutator: VMMutatorThread,
83-
_m: &T,
84-
) {
85-
// do nothing
86-
}
87-
8885
fn vm_live_bytes() -> usize {
8986
(upcalls().vm_live_bytes)()
9087
}
9188
}
89+
90+
impl VMCollection {
91+
extern "C" fn notify_mutator_ready<F>(mutator_ptr: *mut RubyMutator, data: *mut libc::c_void)
92+
where
93+
F: FnMut(&'static mut mmtk::Mutator<Ruby>),
94+
{
95+
let mutator = unsafe { &mut *mutator_ptr };
96+
let mutator_visitor = unsafe { &mut *(data as *mut F) };
97+
mutator_visitor(mutator);
98+
}
99+
}

mmtk/src/scanning.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use mmtk::{memory_manager, Mutator, MutatorContext};
99
pub struct VMScanning {}
1010

1111
impl Scanning<Ruby> for VMScanning {
12-
const SINGLE_THREAD_MUTATOR_SCANNING: bool = false;
13-
1412
fn support_edge_enqueuing(_tls: VMWorkerThread, _object: ObjectReference) -> bool {
1513
false
1614
}
@@ -57,21 +55,14 @@ impl Scanning<Ruby> for VMScanning {
5755
// Do nothing
5856
}
5957

60-
fn scan_roots_in_all_mutator_threads(
61-
_tls: VMWorkerThread,
62-
_factory: impl RootsWorkFactory<RubyEdge>,
63-
) {
64-
unreachable!();
65-
}
66-
6758
fn scan_roots_in_mutator_thread(
6859
tls: VMWorkerThread,
6960
mutator: &'static mut Mutator<Ruby>,
7061
mut factory: impl RootsWorkFactory<RubyEdge>,
7162
) {
7263
let gc_tls = unsafe { GCThreadTLS::from_vwt_check(tls) };
7364
Self::collect_object_roots_in("scan_thread_root", gc_tls, &mut factory, || {
74-
(upcalls().scan_thread_root)(mutator.get_tls(), tls);
65+
(upcalls().scan_roots_in_mutator_thread)(mutator.get_tls(), tls);
7566
});
7667
}
7768

mmtk/src/weak_proc.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ trait GlobalTableProcessingWork {
148148
// `hash_foreach_replace` depends on `gb_object_moved_p` which has to have the semantics
149149
// of `trace_object` due to the way it is used in `UPDATE_IF_MOVED`.
150150
let forward_object = |_worker, object: ObjectReference, _pin| {
151-
debug_assert!(mmtk::memory_manager::is_mmtk_object(
152-
VMObjectModel::ref_to_address(object)
153-
), "{} is not an MMTk object", object);
151+
debug_assert!(
152+
mmtk::memory_manager::is_mmtk_object(VMObjectModel::ref_to_address(object)),
153+
"{} is not an MMTk object",
154+
object
155+
);
154156
let result = object.forward();
155157
trace!("Forwarding reference: {} -> {}", object, result);
156158
result

0 commit comments

Comments
 (0)