Skip to content

Commit 55e4017

Browse files
authored
Clear pin bits (#1166)
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.
1 parent a3a72f8 commit 55e4017

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/policy/immix/block.rs

+17
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use crate::util::linear_scan::{Region, RegionIterator};
88
use crate::util::metadata::side_metadata::{MetadataByteArrayRef, SideMetadataSpec};
99
#[cfg(feature = "vo_bit")]
1010
use crate::util::metadata::vo_bit;
11+
#[cfg(feature = "object_pinning")]
12+
use crate::util::metadata::MetadataSpec;
1113
use crate::util::Address;
1214
use crate::vm::*;
1315
use std::sync::atomic::Ordering;
@@ -201,6 +203,15 @@ impl Block {
201203
#[cfg(feature = "vo_bit")]
202204
vo_bit::helper::on_region_swept::<VM, _>(self, false);
203205

206+
// If the pin bit is not on the side, we cannot bulk zero.
207+
// We shouldn't need to clear it here in that case, since the pin bit
208+
// should be overwritten at each object allocation. The same applies below
209+
// when we are sweeping on a line granularity.
210+
#[cfg(feature = "object_pinning")]
211+
if let MetadataSpec::OnSide(side) = *VM::VMObjectModel::LOCAL_PINNING_BIT_SPEC {
212+
side.bzero_metadata(self.start(), Block::BYTES);
213+
}
214+
204215
// Release the block if it is allocated but not marked by the current GC.
205216
space.release_block(*self);
206217
true
@@ -233,6 +244,12 @@ impl Block {
233244
#[cfg(feature = "immix_zero_on_release")]
234245
crate::util::memory::zero(line.start(), Line::BYTES);
235246

247+
// We need to clear the pin bit if it is on the side, as this line can be reused
248+
#[cfg(feature = "object_pinning")]
249+
if let MetadataSpec::OnSide(side) = *VM::VMObjectModel::LOCAL_PINNING_BIT_SPEC {
250+
side.bzero_metadata(line.start(), Line::BYTES);
251+
}
252+
236253
prev_line_is_marked = false;
237254
}
238255
}

0 commit comments

Comments
 (0)