Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function to print object info from the space for debugging #1269

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions src/mmtk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,3 +597,8 @@ impl<VM: VMBinding> MMTK<VM> {
.initialize_object_metadata(object, false)
}
}

#[no_mangle]
pub fn mmtk_debug_print_object_info(object: crate::util::ObjectReference) {
println!("{}", SFT_MAP.get_checked(object.to_raw_address()).debug_get_object_info(object))
}
4 changes: 4 additions & 0 deletions src/policy/copyspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ impl<VM: VMBinding> SFT for CopySpace<VM> {
let worker = worker.into_mut::<VM>();
self.trace_object(queue, object, self.common.copy, worker)
}

fn debug_get_object_info(&self, object: ObjectReference) -> String {
format!("{}: {:?}, {:?}", self.name(), object_forwarding::debug_get_object_forwarding_info::<VM>(object), crate::policy::sft::debug_get_object_global_info(object))
}
}

impl<VM: VMBinding> Space<VM> for CopySpace<VM> {
Expand Down
6 changes: 6 additions & 0 deletions src/policy/immix/immixspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ impl<VM: VMBinding> SFT for ImmixSpace<VM> {
) -> ObjectReference {
panic!("We do not use SFT to trace objects for Immix. sft_trace_object() cannot be used.")
}

fn debug_get_object_info(&self, object: ObjectReference) -> String {
let line = Line::from_unaligned_address(object.to_raw_address());
let block = Block::from_unaligned_address(object.to_raw_address());
format!("{}: marked = {}, line marked = {}, block state = {:?}, {}, {}", self.name(), self.is_marked(object), line.is_marked(self.mark_state), block.get_state(), object_forwarding::debug_get_object_forwarding_info::<VM>(object), crate::policy::sft::debug_get_object_global_info(object))
}
}

impl<VM: VMBinding> Space<VM> for ImmixSpace<VM> {
Expand Down
4 changes: 4 additions & 0 deletions src/policy/markcompactspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ impl<VM: VMBinding> SFT for MarkCompactSpace<VM> {
// Depending on which trace it is, we should manually call either trace_mark or trace_forward.
panic!("sft_trace_object() cannot be used with mark compact space")
}

fn debug_get_object_info(&self, object: ObjectReference) -> String {
format!("{}: marked = {:?}, head forwarding pointer = {:?}. {}", self.name(), MarkCompactSpace::<VM>::is_marked(object), MarkCompactSpace::<VM>::get_header_forwarding_pointer(object), crate::policy::sft::debug_get_object_global_info(object))
}
}

impl<VM: VMBinding> Space<VM> for MarkCompactSpace<VM> {
Expand Down
13 changes: 13 additions & 0 deletions src/policy/sft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ pub trait SFT {
object: ObjectReference,
worker: GCWorkerMutRef,
) -> ObjectReference;

fn debug_get_object_info(&self, object: ObjectReference) -> String {
crate::policy::sft::debug_get_object_global_info(object)
}
}

pub(crate) fn debug_get_object_global_info(object: ObjectReference) -> String {
let mut ret = String::new();
#[cfg(feature = "vo_bit")]
{
ret += &format!("vo bit = {}", crate::util::metadata::vo_bit::is_vo_bit_set(object));
}
ret
}

// Create erased VM refs for these types that will be used in `sft_trace_object()`.
Expand Down
5 changes: 5 additions & 0 deletions src/util/object_forwarding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,8 @@ pub(super) fn forwarding_bits_offset_in_forwarding_pointer<VM: VMBinding>() -> O
pub(super) fn forwarding_bits_offset_in_forwarding_pointer<VM: VMBinding>() -> Option<isize> {
unimplemented!()
}

pub(crate) fn debug_get_object_forwarding_info<VM: VMBinding>(object: ObjectReference) -> String {
let forwarding_bits = get_forwarding_status::<VM>(object);
format!("forwarding bits = {:?}, forwarding pointer = {:?}", forwarding_bits, if state_is_forwarded_or_being_forwarded(forwarding_bits) { Some(read_forwarding_pointer::<VM>(object)) } else { None })
}
Loading