Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/mmtk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,30 @@ impl<VM: VMBinding> MMTK<VM> {
});
ret
}

/// Print VM maps. It will print the memory ranges used by spaces as well as some attributes of
/// the spaces.
///
/// - "I": The space is immortal. Its objects will never die.
/// - "N": The space is non-movable. Its objects will never move.
///
/// Arguments:
/// * `out`: the place to print the VM maps.
/// * `space_name`: If `None`, print all spaces;
/// if `Some(n)`, only print the space whose name is `n`.
pub fn debug_print_vm_maps(
&self,
out: &mut impl std::fmt::Write,
space_name: Option<&str>,
) -> Result<(), std::fmt::Error> {
let mut result_so_far = Ok(());
self.get_plan().for_each_space(&mut |space| {
if result_so_far.is_ok()
&& (space_name.is_none() || space_name == Some(space.get_name()))
{
result_so_far = crate::policy::space::print_vm_map(space, out);
}
});
result_so_far
}
}
13 changes: 13 additions & 0 deletions src/util/api_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use super::{Address, ObjectReference};
/// It is intended for passing an `Option<ObjectReference>` values to and from native programs
/// (usually C or C++) that have null pointers.
#[repr(transparent)]
#[derive(Clone, Copy)]
pub struct NullableObjectReference(usize);

impl From<NullableObjectReference> for Option<ObjectReference> {
Expand All @@ -31,3 +32,15 @@ impl From<Option<ObjectReference>> for NullableObjectReference {
Self(encoded)
}
}

impl std::fmt::Display for NullableObjectReference {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:#x}", self.0)
}
}

impl std::fmt::Debug for NullableObjectReference {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self, f)
}
}
Loading