Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wks committed Jan 7, 2025
1 parent 6e91fc3 commit 357abe7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/policy/marksweepspace/native_ms/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,23 @@ impl<VM: VMBinding> MarkSweepSpace<VM> {

/// Mark an object atomically.
fn attempt_mark_atomic(&self, object: ObjectReference) -> bool {
let mark_state = 1u8;

loop {
let old_value = VM::VMObjectModel::LOCAL_MARK_BIT_SPEC.load_atomic::<VM, u8>(
object,
None,
Ordering::SeqCst,
);
if old_value == 1u8 {
if old_value == mark_state {
return false;
}

if VM::VMObjectModel::LOCAL_MARK_BIT_SPEC
.compare_exchange_metadata::<VM, u8>(
object,
old_value,
1u8,
mark_state,
None,
Ordering::SeqCst,
Ordering::SeqCst,
Expand Down Expand Up @@ -389,8 +391,7 @@ impl<VM: VMBinding> MarkSweepSpace<VM> {
"Cannot mark an object {} that was not alloced by free list allocator.",
object,
);
if !VM::VMObjectModel::LOCAL_MARK_BIT_SPEC.is_marked::<VM>(object, Ordering::SeqCst) {
VM::VMObjectModel::LOCAL_MARK_BIT_SPEC.mark::<VM>(object, Ordering::SeqCst);
if self.attempt_mark(object) {
let block = Block::containing(object);
block.set_state(BlockState::Marked);
queue.enqueue(object);
Expand Down

0 comments on commit 357abe7

Please sign in to comment.