Skip to content
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
4 changes: 2 additions & 2 deletions mmtk/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ pub struct RubyUpcalls {
data: *mut libc::c_void,
),
pub scan_vm_specific_roots: extern "C" fn(),
pub scan_thread_roots: extern "C" fn(),
pub scan_thread_root: extern "C" fn(mutator_tls: VMMutatorThread, worker_tls: VMWorkerThread),
pub scan_roots_in_mutator_thread:
extern "C" fn(mutator_tls: VMMutatorThread, worker_tls: VMWorkerThread),
pub scan_object_ruby_style: extern "C" fn(object: ObjectReference),
pub call_gc_mark_children: extern "C" fn(object: ObjectReference),
pub call_obj_free: extern "C" fn(object: ObjectReference),
Expand Down
28 changes: 18 additions & 10 deletions mmtk/src/collection.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
use crate::abi::GCThreadTLS;

use crate::api::RubyMutator;
use crate::{mmtk, upcalls, Ruby};
use mmtk::memory_manager;
use mmtk::scheduler::*;
use mmtk::util::{VMMutatorThread, VMThread, VMWorkerThread};
use mmtk::vm::{Collection, GCThreadContext};
use mmtk::{memory_manager, MutatorContext};
use std::thread;

pub struct VMCollection {}

impl Collection<Ruby> for VMCollection {
fn stop_all_mutators<F>(tls: VMWorkerThread, _mutator_visitor: F)
fn stop_all_mutators<F>(tls: VMWorkerThread, mut mutator_visitor: F)
where
F: FnMut(&'static mut mmtk::Mutator<Ruby>),
{
(upcalls().stop_the_world)(tls);
crate::binding().ppp_registry.pin_ppp_children(tls);
(upcalls().get_mutators)(
Self::notify_mutator_ready::<F>,
&mut mutator_visitor as *mut F as *mut _,
);
}

fn resume_mutators(tls: VMWorkerThread) {
Expand Down Expand Up @@ -77,15 +82,18 @@ impl Collection<Ruby> for VMCollection {
}
}

fn prepare_mutator<T: MutatorContext<Ruby>>(
_tls_worker: VMWorkerThread,
_tls_mutator: VMMutatorThread,
_m: &T,
) {
// do nothing
}

fn vm_live_bytes() -> usize {
(upcalls().vm_live_bytes)()
}
}

impl VMCollection {
extern "C" fn notify_mutator_ready<F>(mutator_ptr: *mut RubyMutator, data: *mut libc::c_void)
where
F: FnMut(&'static mut mmtk::Mutator<Ruby>),
{
let mutator = unsafe { &mut *mutator_ptr };
let mutator_visitor = unsafe { &mut *(data as *mut F) };
mutator_visitor(mutator);
}
}
11 changes: 1 addition & 10 deletions mmtk/src/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use mmtk::{memory_manager, Mutator, MutatorContext};
pub struct VMScanning {}

impl Scanning<Ruby> for VMScanning {
const SINGLE_THREAD_MUTATOR_SCANNING: bool = false;

fn support_edge_enqueuing(_tls: VMWorkerThread, _object: ObjectReference) -> bool {
false
}
Expand Down Expand Up @@ -57,21 +55,14 @@ impl Scanning<Ruby> for VMScanning {
// Do nothing
}

fn scan_roots_in_all_mutator_threads(
_tls: VMWorkerThread,
_factory: impl RootsWorkFactory<RubyEdge>,
) {
unreachable!();
}

fn scan_roots_in_mutator_thread(
tls: VMWorkerThread,
mutator: &'static mut Mutator<Ruby>,
mut factory: impl RootsWorkFactory<RubyEdge>,
) {
let gc_tls = unsafe { GCThreadTLS::from_vwt_check(tls) };
Self::collect_object_roots_in("scan_thread_root", gc_tls, &mut factory, || {
(upcalls().scan_thread_root)(mutator.get_tls(), tls);
(upcalls().scan_roots_in_mutator_thread)(mutator.get_tls(), tls);
});
}

Expand Down
8 changes: 5 additions & 3 deletions mmtk/src/weak_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ trait GlobalTableProcessingWork {
// `hash_foreach_replace` depends on `gb_object_moved_p` which has to have the semantics
// of `trace_object` due to the way it is used in `UPDATE_IF_MOVED`.
let forward_object = |_worker, object: ObjectReference, _pin| {
debug_assert!(mmtk::memory_manager::is_mmtk_object(
VMObjectModel::ref_to_address(object)
), "{} is not an MMTk object", object);
debug_assert!(
mmtk::memory_manager::is_mmtk_object(VMObjectModel::ref_to_address(object)),
"{} is not an MMTk object",
object
);
let result = object.forward();
trace!("Forwarding reference: {} -> {}", object, result);
result
Expand Down