Skip to content

Commit

Permalink
Clear pin bits (#1166)
Browse files Browse the repository at this point in the history
If an object dies, we need to make sure his pin bit gets cleared. This
PR enables clearing the pin bits when sweeping - clearing the whole
block when `super::BLOCK_ONLY` is true, or at line granularity when a
line is not marked.
I've only added it to the immix policy, since for everything else
pinning is either unsupported or it's a NOP.
  • Loading branch information
udesou authored Jul 12, 2024
1 parent a3a72f8 commit 55e4017
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/policy/immix/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use crate::util::linear_scan::{Region, RegionIterator};
use crate::util::metadata::side_metadata::{MetadataByteArrayRef, SideMetadataSpec};
#[cfg(feature = "vo_bit")]
use crate::util::metadata::vo_bit;
#[cfg(feature = "object_pinning")]
use crate::util::metadata::MetadataSpec;
use crate::util::Address;
use crate::vm::*;
use std::sync::atomic::Ordering;
Expand Down Expand Up @@ -201,6 +203,15 @@ impl Block {
#[cfg(feature = "vo_bit")]
vo_bit::helper::on_region_swept::<VM, _>(self, false);

// If the pin bit is not on the side, we cannot bulk zero.
// We shouldn't need to clear it here in that case, since the pin bit
// should be overwritten at each object allocation. The same applies below
// when we are sweeping on a line granularity.
#[cfg(feature = "object_pinning")]
if let MetadataSpec::OnSide(side) = *VM::VMObjectModel::LOCAL_PINNING_BIT_SPEC {
side.bzero_metadata(self.start(), Block::BYTES);
}

// Release the block if it is allocated but not marked by the current GC.
space.release_block(*self);
true
Expand Down Expand Up @@ -233,6 +244,12 @@ impl Block {
#[cfg(feature = "immix_zero_on_release")]
crate::util::memory::zero(line.start(), Line::BYTES);

// We need to clear the pin bit if it is on the side, as this line can be reused
#[cfg(feature = "object_pinning")]
if let MetadataSpec::OnSide(side) = *VM::VMObjectModel::LOCAL_PINNING_BIT_SPEC {
side.bzero_metadata(line.start(), Line::BYTES);
}

prev_line_is_marked = false;
}
}
Expand Down

0 comments on commit 55e4017

Please sign in to comment.