From b567cc4dbdd7b765d38b15d52488e1f5b30bd3cb Mon Sep 17 00:00:00 2001 From: Kunshan Wang Date: Fri, 13 Oct 2023 11:26:11 +0800 Subject: [PATCH] Stop using the name "ForwardingWord" (#976) The name is likely inherited from JikesRVM. But since we changed its name, we should just use the module name "object_forwarding" directly. This cleans up some naming issues, and prepares for subsequent refactoring that intends to change the logic of object forwarding in ImmixSpace. At that time, I intend to fix this naming issue anyway. Co-authored-by: Zixian Cai <2891235+caizixian@users.noreply.github.com> --- src/policy/immix/immixspace.rs | 20 ++++++++++---------- src/util/object_forwarding.rs | 3 +-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/policy/immix/immixspace.rs b/src/policy/immix/immixspace.rs index e699443800..65405a8ab2 100644 --- a/src/policy/immix/immixspace.rs +++ b/src/policy/immix/immixspace.rs @@ -16,7 +16,7 @@ use crate::util::metadata::side_metadata::SideMetadataSpec; #[cfg(feature = "vo_bit")] use crate::util::metadata::vo_bit; use crate::util::metadata::{self, MetadataSpec}; -use crate::util::object_forwarding as ForwardingWord; +use crate::util::object_forwarding; use crate::util::{Address, ObjectReference}; use crate::vm::*; use crate::{ @@ -91,8 +91,8 @@ impl SFT for ImmixSpace { return None; } - if ForwardingWord::is_forwarded::(object) { - Some(ForwardingWord::read_forwarding_pointer::(object)) + if object_forwarding::is_forwarded::(object) { + Some(object_forwarding::read_forwarding_pointer::(object)) } else { None } @@ -110,7 +110,7 @@ impl SFT for ImmixSpace { } // If the object is forwarded, it is live, too. - ForwardingWord::is_forwarded::(object) + object_forwarding::is_forwarded::(object) } #[cfg(feature = "object_pinning")] fn pin_object(&self, object: ObjectReference) -> bool { @@ -581,14 +581,14 @@ impl ImmixSpace { #[cfg(feature = "vo_bit")] vo_bit::helper::on_trace_object::(object); - let forwarding_status = ForwardingWord::attempt_to_forward::(object); - if ForwardingWord::state_is_forwarded_or_being_forwarded(forwarding_status) { + let forwarding_status = object_forwarding::attempt_to_forward::(object); + if object_forwarding::state_is_forwarded_or_being_forwarded(forwarding_status) { // We lost the forwarding race as some other thread has set the forwarding word; wait // until the object has been forwarded by the winner. Note that the object may not // necessarily get forwarded since Immix opportunistically moves objects. #[allow(clippy::let_and_return)] let new_object = - ForwardingWord::spin_and_get_forwarded_object::(object, forwarding_status); + object_forwarding::spin_and_get_forwarded_object::(object, forwarding_status); #[cfg(debug_assertions)] { if new_object == object { @@ -611,7 +611,7 @@ impl ImmixSpace { } else if self.is_marked(object) { // We won the forwarding race but the object is already marked so we clear the // forwarding status and return the unmoved object - ForwardingWord::clear_forwarding_bits::(object); + object_forwarding::clear_forwarding_bits::(object); object } else { // We won the forwarding race; actually forward and copy the object if it is not pinned @@ -620,7 +620,7 @@ impl ImmixSpace { || (!nursery_collection && self.defrag.space_exhausted()) { self.attempt_mark(object, self.mark_state); - ForwardingWord::clear_forwarding_bits::(object); + object_forwarding::clear_forwarding_bits::(object); Block::containing::(object).set_state(BlockState::Marked); #[cfg(feature = "vo_bit")] @@ -634,7 +634,7 @@ impl ImmixSpace { // Clippy complains if the "vo_bit" feature is not enabled. #[allow(clippy::let_and_return)] let new_object = - ForwardingWord::forward_object::(object, semantics, copy_context); + object_forwarding::forward_object::(object, semantics, copy_context); #[cfg(feature = "vo_bit")] vo_bit::helper::on_object_forwarded::(new_object); diff --git a/src/util/object_forwarding.rs b/src/util/object_forwarding.rs index f7a4bea239..01b3fec447 100644 --- a/src/util/object_forwarding.rs +++ b/src/util/object_forwarding.rs @@ -1,6 +1,5 @@ use crate::util::copy::*; use crate::util::metadata::MetadataSpec; -/// https://github.com/JikesRVM/JikesRVM/blob/master/MMTk/src/org/mmtk/utility/ForwardingWord.java use crate::util::{constants, ObjectReference}; use crate::vm::ObjectModel; use crate::vm::VMBinding; @@ -174,7 +173,7 @@ pub fn write_forwarding_pointer( get_forwarding_status::(object), ); - trace!("GCForwardingWord::write({:#?}, {:x})\n", object, new_object); + trace!("write_forwarding_pointer({}, {})", object, new_object); VM::VMObjectModel::LOCAL_FORWARDING_POINTER_SPEC.store_atomic::( object, new_object.to_raw_address().as_usize(),