@@ -41,9 +41,35 @@ use crate::util::{Address, ObjectReference};
41
41
/// in a word as a pointer, it can also use `SimpleEdge` for weak reference fields.
42
42
pub trait Edge : Copy + Send + Debug + PartialEq + Eq + Hash {
43
43
/// 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.
44
62
fn load ( & self ) -> ObjectReference ;
45
63
46
64
/// 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
47
73
fn store ( & self , object : ObjectReference ) ;
48
74
49
75
/// Prefetch the edge so that a subsequent `load` will be faster.
0 commit comments