Skip to content

Commit d977063

Browse files
committed
Minor updates to the docs on is_mmtk_object
1 parent 29dfce4 commit d977063

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

docs/userguide/src/migration/prefix.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ API changes:
4444
* trait `ObjectModel`
4545
- The methods `ref_to_address` and `address_to_ref` are removed.
4646
- Users are required to specify `IN_OBJECT_ADDRESS_OFFSET` instead, which is the offset from the object
47-
reference to the in-object address (which was returned in the old `ref_to_address()`).
47+
reference to the in-object address (the in-object address was the return value for the old `ref_to_address()`).
48+
* type `ObjectReference`
49+
- Add a constant `ALIGNMENT` which equals to the word size. All object references should be at least aligned
50+
to the word size. This is checked in debug builds when an `ObjectReference` is constructed.
4851

4952
## 0.26.0
5053

src/memory_manager.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,6 @@ pub fn is_live_object<VM: VMBinding>(object: ObjectReference) -> bool {
597597
/// It is the byte granularity of the valid object (VO) bit.
598598
/// 3. Return false otherwise. This function never panics.
599599
///
600-
/// Case 2 means **this function is imprecise for misaligned addresses**.
601600
/// This function uses the "valid object (VO) bits" side metadata, i.e. a bitmap.
602601
/// For space efficiency, each bit of the bitmap governs a small region of memory.
603602
/// The size of a region is currently defined as the [minimum object size](crate::util::constants::MIN_OBJECT_SIZE),
@@ -606,13 +605,8 @@ pub fn is_live_object<VM: VMBinding>(object: ObjectReference) -> bool {
606605
/// The alignment of a region is also the region size.
607606
/// If a VO bit is `1`, the bitmap cannot tell which address within the 4-byte or 8-byte region
608607
/// is the valid object reference.
609-
/// Therefore, if the input `addr` is not properly aligned, but is close to a valid object
610-
/// reference, this function may still return true.
611-
///
612-
/// For the reason above, the VM **must check if `addr` is properly aligned** before calling this
613-
/// function. For most VMs, valid object references are always aligned to the word size, so
614-
/// checking `addr.is_aligned_to(BYTES_IN_WORD)` should usually work. If you are paranoid, you can
615-
/// always check against [`crate::util::is_mmtk_object::VO_BIT_REGION_SIZE`].
608+
/// Therefore, if this method returns true, the binding can compute the object reference by
609+
/// `(addr + IN_OBJECT_ADDRESS_OFFSET).align_up(ObjectReference::ALIGNMENT)` ([`crate::vm::ObjectModel::IN_OBJECT_ADDRESS_OFFSET`]).
616610
///
617611
/// This function is useful for conservative root scanning. The VM can iterate through all words in
618612
/// a stack, filter out zeros, misaligned words, obviously out-of-range words (such as addresses

0 commit comments

Comments
 (0)