Skip to content

Commit 50425f9

Browse files
committed
Move constant to Scanning
1 parent 357abe7 commit 50425f9

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/policy/marksweepspace/native_ms/global.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::util::heap::chunk_map::*;
2929
use crate::util::linear_scan::Region;
3030
use crate::util::VMThread;
3131
use crate::vm::ObjectModel;
32+
use crate::vm::Scanning;
3233
use std::sync::Mutex;
3334

3435
/// The result for `MarkSweepSpace.acquire_block()`. `MarkSweepSpace` will attempt
@@ -374,7 +375,7 @@ impl<VM: VMBinding> MarkSweepSpace<VM> {
374375
/// Mark an object. Return `true` if the object is newly marked. Return `false` if the object
375376
/// was already marked.
376377
fn attempt_mark(&self, object: ObjectReference) -> bool {
377-
if VM::UNIQUE_OBJECT_ENQUEUING {
378+
if VM::VMScanning::UNIQUE_OBJECT_ENQUEUING {
378379
self.attempt_mark_atomic(object)
379380
} else {
380381
self.attempt_mark_non_atomic(object)

src/vm/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,4 @@ where
7979
/// Note that MMTk does not attempt to do anything to align the cursor to this value, but
8080
/// it merely asserts with this constant.
8181
const ALLOC_END_ALIGNMENT: usize = 1;
82-
83-
/// When set to `true`, all plans will guarantee that during each GC, each live object is
84-
/// enqueued at most once, and therefore scanned (by either [`Scanning::scan_object`] or
85-
/// [`Scanning::scan_object_and_trace_edges`]) at most once.
86-
///
87-
/// When set to `false`, MMTk may enqueue an object multiple times due to optimizations, such as
88-
/// using non-atomic operatios to mark objects. Consequently, an object may be scanned multiple
89-
/// times during a GC.
90-
///
91-
/// The default value is `false` because duplicated object-enqueuing is benign for most VMs, and
92-
/// related optimizations, such as non-atomic marking, can improve GC speed. VM bindings can
93-
/// override this if they need. For example, some VMs piggyback on object-scanning to visit
94-
/// objects during a GC, but may have data race if multiple GC workers visit the same object at
95-
/// the same time. Such VMs can set this constant to `true` to workaround this problem.
96-
const UNIQUE_OBJECT_ENQUEUING: bool = false;
9782
}

src/vm/scanning.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,21 @@ pub trait RootsWorkFactory<SL: Slot>: Clone + Send + 'static {
140140

141141
/// VM-specific methods for scanning roots/objects.
142142
pub trait Scanning<VM: VMBinding> {
143+
/// When set to `true`, all plans will guarantee that during each GC, each live object is
144+
/// enqueued at most once, and therefore scanned (by either [`Scanning::scan_object`] or
145+
/// [`Scanning::scan_object_and_trace_edges`]) at most once.
146+
///
147+
/// When set to `false`, MMTk may enqueue an object multiple times due to optimizations, such as
148+
/// using non-atomic operatios to mark objects. Consequently, an object may be scanned multiple
149+
/// times during a GC.
150+
///
151+
/// The default value is `false` because duplicated object-enqueuing is benign for most VMs, and
152+
/// related optimizations, such as non-atomic marking, can improve GC speed. VM bindings can
153+
/// override this if they need. For example, some VMs piggyback on object-scanning to visit
154+
/// objects during a GC, but may have data race if multiple GC workers visit the same object at
155+
/// the same time. Such VMs can set this constant to `true` to workaround this problem.
156+
const UNIQUE_OBJECT_ENQUEUING: bool = false;
157+
143158
/// Return true if the given object supports slot enqueuing.
144159
///
145160
/// - If this returns true, MMTk core will call `scan_object` on the object.

0 commit comments

Comments
 (0)