[ruby/mmtk] Do root scanning in scan_vm_specific_roots
We rely on scan_vm_specific_roots to reach all stacks via the following path: VM -> ractors -> threads -> fibers -> stacks https://github.com/ruby/mmtk/commit/0a6a835aaa
This commit is contained in:
parent
b3b1d7b295
commit
d17ab5a430
@ -201,7 +201,13 @@ rb_mmtk_get_mutators(void (*visit_mutator)(MMTk_Mutator *mutator, void *data), v
|
||||
static void
|
||||
rb_mmtk_scan_gc_roots(void)
|
||||
{
|
||||
// rb_gc_mark_roots(rb_gc_get_objspace(), NULL);
|
||||
struct objspace *objspace = rb_gc_get_objspace();
|
||||
|
||||
// FIXME: Make `rb_gc_mark_roots` aware that the current thread may not have EC.
|
||||
// See: https://github.com/ruby/mmtk/issues/22
|
||||
rb_gc_worker_thread_set_vm_context(&objspace->vm_context);
|
||||
rb_gc_mark_roots(objspace, NULL);
|
||||
rb_gc_worker_thread_unset_vm_context(&objspace->vm_context);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -240,18 +246,6 @@ rb_mmtk_scan_objspace(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rb_mmtk_scan_roots_in_mutator_thread(MMTk_VMMutatorThread mutator, MMTk_VMWorkerThread worker)
|
||||
{
|
||||
if (mutator->gc_mutator_p) {
|
||||
struct objspace *objspace = rb_gc_get_objspace();
|
||||
|
||||
rb_gc_worker_thread_set_vm_context(&objspace->vm_context);
|
||||
rb_gc_mark_roots(objspace, NULL);
|
||||
rb_gc_worker_thread_unset_vm_context(&objspace->vm_context);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rb_mmtk_scan_object_ruby_style(MMTk_ObjectReference object)
|
||||
{
|
||||
@ -400,7 +394,6 @@ MMTk_RubyUpcalls ruby_upcalls = {
|
||||
rb_mmtk_get_mutators,
|
||||
rb_mmtk_scan_gc_roots,
|
||||
rb_mmtk_scan_objspace,
|
||||
rb_mmtk_scan_roots_in_mutator_thread,
|
||||
rb_mmtk_scan_object_ruby_style,
|
||||
rb_mmtk_call_gc_mark_children,
|
||||
rb_mmtk_call_obj_free,
|
||||
|
@ -61,8 +61,6 @@ typedef struct MMTk_RubyUpcalls {
|
||||
void (*get_mutators)(void (*visit_mutator)(MMTk_Mutator*, void*), void *data);
|
||||
void (*scan_gc_roots)(void);
|
||||
void (*scan_objspace)(void);
|
||||
void (*scan_roots_in_mutator_thread)(MMTk_VMMutatorThread mutator_tls,
|
||||
MMTk_VMWorkerThread worker_tls);
|
||||
void (*scan_object_ruby_style)(MMTk_ObjectReference object);
|
||||
void (*call_gc_mark_children)(MMTk_ObjectReference object);
|
||||
void (*call_obj_free)(MMTk_ObjectReference object);
|
||||
|
@ -315,8 +315,6 @@ pub struct RubyUpcalls {
|
||||
),
|
||||
pub scan_gc_roots: extern "C" fn(),
|
||||
pub scan_objspace: extern "C" fn(),
|
||||
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),
|
||||
|
@ -5,7 +5,7 @@ use crate::{upcalls, Ruby, RubySlot};
|
||||
use mmtk::scheduler::{GCWork, GCWorker, WorkBucketStage};
|
||||
use mmtk::util::{ObjectReference, VMWorkerThread};
|
||||
use mmtk::vm::{ObjectTracer, RootsWorkFactory, Scanning, SlotVisitor};
|
||||
use mmtk::{Mutator, MutatorContext};
|
||||
use mmtk::Mutator;
|
||||
|
||||
pub struct VMScanning {}
|
||||
|
||||
@ -67,14 +67,13 @@ impl Scanning<Ruby> for VMScanning {
|
||||
}
|
||||
|
||||
fn scan_roots_in_mutator_thread(
|
||||
tls: VMWorkerThread,
|
||||
mutator: &'static mut Mutator<Ruby>,
|
||||
mut factory: impl RootsWorkFactory<RubySlot>,
|
||||
_tls: VMWorkerThread,
|
||||
_mutator: &'static mut Mutator<Ruby>,
|
||||
mut _factory: impl RootsWorkFactory<RubySlot>,
|
||||
) {
|
||||
let gc_tls = unsafe { GCThreadTLS::from_vwt_check(tls) };
|
||||
Self::collect_object_roots_in("scan_thread_root", gc_tls, &mut factory, || {
|
||||
(upcalls().scan_roots_in_mutator_thread)(mutator.get_tls(), tls);
|
||||
});
|
||||
// Do nothing. All stacks (including Ruby stacks and machine stacks) are reachable from
|
||||
// `rb_vm_t` -> ractor -> thread -> fiber -> stacks. It is part of `ScanGCRoots` which
|
||||
// calls `rb_gc_mark_roots` -> `rb_vm_mark`.
|
||||
}
|
||||
|
||||
fn scan_vm_specific_roots(tls: VMWorkerThread, factory: impl RootsWorkFactory<RubySlot>) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user