Skip to content

Commit 01865db

Browse files
committed
Update documentation
Update the doc comments of `Edge::load` and `Edge::store` to mention tagged references.
1 parent 7b08673 commit 01865db

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/vm/edge_shape.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,35 @@ use crate::util::{Address, ObjectReference};
4141
/// in a word as a pointer, it can also use `SimpleEdge` for weak reference fields.
4242
pub trait Edge: Copy + Send + Debug + PartialEq + Eq + Hash {
4343
/// Load object reference from the edge.
44+
///
45+
/// If the slot is not holding an object reference, it should return `ObjectReference::NULL`.
46+
/// Specifically,
47+
///
48+
/// - If the langauge has the concept of "null pointer" which does not point to any object in
49+
/// the heap, this method should return `ObjectReference::NULL` regardless how a null
50+
/// pointer is encoded in the VM. However, if the VM uses a special object in the heap to
51+
/// represent a null value, such as the `None` object of `NoneType` in Python, this method
52+
/// should still return the object reference to such `None` objects so that they are
53+
/// properly traced, kept alive, and they have their references forwarded.
54+
/// - If, in a VM, the data type a slot can hold is a union of references and non-reference
55+
/// values, and the slot is currently holding a non-reference value, such as a small
56+
/// integer, a floating-point number, or any special value such as `true`, `false` or `nil`
57+
/// that do not point to any object, the slot is considered not holding an reference. This
58+
/// method should return `ObjectReference::NULL` in such cases.
59+
///
60+
/// If the slot holds an object reference with tag bits, the returned value shall be the object
61+
/// reference with the tag bits removed.
4462
fn load(&self) -> ObjectReference;
4563

4664
/// Store the object reference `object` into the edge.
65+
///
66+
/// If the slot holds an object reference with tag bits, this method must preserve the tag
67+
/// bits while updating the object reference so that it points to the forwarded object given by
68+
/// the parameter `object`.
69+
///
70+
/// FIXME: This design is inefficient for handling object references with tag bits. Consider
71+
/// introducing a new updating function to do the load, trace and store in one function.
72+
/// See: https://github.com/mmtk/mmtk-core/issues/1033
4773
fn store(&self, object: ObjectReference);
4874

4975
/// Prefetch the edge so that a subsequent `load` will be faster.

0 commit comments

Comments
 (0)