1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
use crate::plan::{Mutator, TransitiveClosure}; use crate::scheduler::gc_work::ProcessEdgesWork; use crate::scheduler::GCWorker; use crate::util::ObjectReference; use crate::util::OpaquePointer; use crate::vm::VMBinding; /// VM-specific methods for scanning roots/objects. pub trait Scanning<VM: VMBinding> { /// Scan stack roots after all mutators are paused. const SCAN_MUTATORS_IN_SAFEPOINT: bool = true; /// Scan all the mutators within a single work packet. /// /// `SCAN_MUTATORS_IN_SAFEPOINT` should also be enabled const SINGLE_THREAD_MUTATOR_SCANNING: bool = true; /// Delegated scanning of a object, processing each pointer field /// encountered. This method probably will be removed in the future, /// in favor of bulk scanning `scan_objects`. /// /// Arguments: /// * `trace`: The `TransitiveClosure` to use for scanning. /// * `object`: The object to be scanned. /// * `tls`: The GC worker thread that is doing this tracing. fn scan_object<T: TransitiveClosure>( trace: &mut T, object: ObjectReference, tls: OpaquePointer, ); /// MMTk calls this method at the first time during a collection that thread's stacks /// have been scanned. This can be used (for example) to clean up /// obsolete compiled methods that are no longer being executed. /// /// Arguments: /// * `partial_scan`: Whether the scan was partial or full-heap. /// * `tls`: The GC thread that is performing the thread scan. fn notify_initial_thread_scan_complete(partial_scan: bool, tls: OpaquePointer); /// Bulk scanning of objects, processing each pointer field for each object. /// /// Arguments: /// * `objects`: The slice of object references to be scanned. fn scan_objects<W: ProcessEdgesWork<VM = VM>>( objects: &[ObjectReference], worker: &mut GCWorker<VM>, ); /// Scan all the mutators for roots. fn scan_thread_roots<W: ProcessEdgesWork<VM = VM>>(); /// Scan one mutator for roots. /// /// Arguments: /// * `mutator`: The reference to the mutator whose roots will be scanned. /// * `tls`: The GC thread that is performing this scanning. fn scan_thread_root<W: ProcessEdgesWork<VM = VM>>( mutator: &'static mut Mutator<VM>, tls: OpaquePointer, ); /// Scan VM-specific roots. The creation of all root scan tasks (except thread scanning) /// goes here. fn scan_vm_specific_roots<W: ProcessEdgesWork<VM = VM>>(); /// Return whether the VM supports return barriers. This is unused at the moment. fn supports_return_barrier() -> bool; }