Skip to content

Commit

Permalink
Stop using the name "ForwardingWord" (#976)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
wks and caizixian authored Oct 13, 2023
1 parent 29e37b8 commit b567cc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/policy/immix/immixspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -91,8 +91,8 @@ impl<VM: VMBinding> SFT for ImmixSpace<VM> {
return None;
}

if ForwardingWord::is_forwarded::<VM>(object) {
Some(ForwardingWord::read_forwarding_pointer::<VM>(object))
if object_forwarding::is_forwarded::<VM>(object) {
Some(object_forwarding::read_forwarding_pointer::<VM>(object))
} else {
None
}
Expand All @@ -110,7 +110,7 @@ impl<VM: VMBinding> SFT for ImmixSpace<VM> {
}

// If the object is forwarded, it is live, too.
ForwardingWord::is_forwarded::<VM>(object)
object_forwarding::is_forwarded::<VM>(object)
}
#[cfg(feature = "object_pinning")]
fn pin_object(&self, object: ObjectReference) -> bool {
Expand Down Expand Up @@ -581,14 +581,14 @@ impl<VM: VMBinding> ImmixSpace<VM> {
#[cfg(feature = "vo_bit")]
vo_bit::helper::on_trace_object::<VM>(object);

let forwarding_status = ForwardingWord::attempt_to_forward::<VM>(object);
if ForwardingWord::state_is_forwarded_or_being_forwarded(forwarding_status) {
let forwarding_status = object_forwarding::attempt_to_forward::<VM>(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::<VM>(object, forwarding_status);
object_forwarding::spin_and_get_forwarded_object::<VM>(object, forwarding_status);
#[cfg(debug_assertions)]
{
if new_object == object {
Expand All @@ -611,7 +611,7 @@ impl<VM: VMBinding> ImmixSpace<VM> {
} 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::<VM>(object);
object_forwarding::clear_forwarding_bits::<VM>(object);
object
} else {
// We won the forwarding race; actually forward and copy the object if it is not pinned
Expand All @@ -620,7 +620,7 @@ impl<VM: VMBinding> ImmixSpace<VM> {
|| (!nursery_collection && self.defrag.space_exhausted())
{
self.attempt_mark(object, self.mark_state);
ForwardingWord::clear_forwarding_bits::<VM>(object);
object_forwarding::clear_forwarding_bits::<VM>(object);
Block::containing::<VM>(object).set_state(BlockState::Marked);

#[cfg(feature = "vo_bit")]
Expand All @@ -634,7 +634,7 @@ impl<VM: VMBinding> ImmixSpace<VM> {
// Clippy complains if the "vo_bit" feature is not enabled.
#[allow(clippy::let_and_return)]
let new_object =
ForwardingWord::forward_object::<VM>(object, semantics, copy_context);
object_forwarding::forward_object::<VM>(object, semantics, copy_context);

#[cfg(feature = "vo_bit")]
vo_bit::helper::on_object_forwarded::<VM>(new_object);
Expand Down
3 changes: 1 addition & 2 deletions src/util/object_forwarding.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -174,7 +173,7 @@ pub fn write_forwarding_pointer<VM: VMBinding>(
get_forwarding_status::<VM>(object),
);

trace!("GCForwardingWord::write({:#?}, {:x})\n", object, new_object);
trace!("write_forwarding_pointer({}, {})", object, new_object);
VM::VMObjectModel::LOCAL_FORWARDING_POINTER_SPEC.store_atomic::<VM, usize>(
object,
new_object.to_raw_address().as_usize(),
Expand Down

0 comments on commit b567cc4

Please sign in to comment.