Skip to content

Commit

Permalink
Update doc comment and add assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
wks committed Dec 19, 2023
1 parent 5aa3392 commit afb4beb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/scheduler/gc_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,8 @@ pub(crate) struct ProcessEdgesWorkTracer<E: ProcessEdgesWork> {
impl<E: ProcessEdgesWork> ObjectTracer for ProcessEdgesWorkTracer<E> {
/// Forward the `trace_object` call to the underlying `ProcessEdgesWork`,
/// and flush as soon as the underlying buffer of `process_edges_work` is full.
///
/// This function is inlined because `trace_object` is probably the hottest function in MMTk.
/// If this function is called in small closures, please profile the program and make sure the
/// closure is inlined, too.
fn trace_object(&mut self, object: ObjectReference) -> ObjectReference {
debug_assert!(!object.is_null());
let result = self.process_edges_work.trace_object(object);
self.flush_if_full();
result
Expand Down
11 changes: 7 additions & 4 deletions src/vm/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ impl<ES: Edge, F: FnMut(ES)> EdgeVisitor<ES> for F {

/// Callback trait of scanning functions that directly trace through edges.
pub trait ObjectTracer {
/// Call this function for the content of each edge,
/// and assign the returned value back to the edge.
/// Call this function to trace through an object graph edge which points to `object`.
/// `object` must point to a valid object, and cannot be `ObjectReference::NULL`.
///
/// Note: This function is performance-critical.
/// Implementations should consider inlining if necessary.
/// The return value is the new object reference for `object` if it is moved, or `object` if
/// not moved. If moved, the caller should update the slot that holds the reference to
/// `object` so that it points to the new location.
///
/// Note: This function is performance-critical, therefore must be implemented efficiently.
fn trace_object(&mut self, object: ObjectReference) -> ObjectReference;
}

Expand Down

0 comments on commit afb4beb

Please sign in to comment.