From 89f6b5202eea1e90ea2f6d37cfb6271f2d482c8f Mon Sep 17 00:00:00 2001 From: Kunshan Wang Date: Fri, 6 Sep 2024 17:43:20 +0800 Subject: [PATCH] Require ObjectReference to point inside object (#100) This makes changes for upstream API changes. Upstream PR: https://github.com/mmtk/mmtk-core/pull/1195 --------- Co-authored-by: mmtkgc-bot --- mmtk/Cargo.lock | 4 ++-- mmtk/Cargo.toml | 4 ++-- mmtk/src/api.rs | 14 +++++++------- mmtk/src/object_model.rs | 2 -- mmtk/src/ppp.rs | 8 ++++---- mmtk/src/scanning.rs | 2 +- mmtk/src/weak_proc.rs | 8 ++++---- 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/mmtk/Cargo.lock b/mmtk/Cargo.lock index 3896830..9419f71 100644 --- a/mmtk/Cargo.lock +++ b/mmtk/Cargo.lock @@ -438,7 +438,7 @@ dependencies = [ [[package]] name = "mmtk" version = "0.27.0" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=fa5327544e2546654a6d89ed5db4509966e89182#fa5327544e2546654a6d89ed5db4509966e89182" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=45cdf31055b1b6a629bdb8032adaa6dd5a8e32b9#45cdf31055b1b6a629bdb8032adaa6dd5a8e32b9" dependencies = [ "atomic", "atomic-traits", @@ -474,7 +474,7 @@ dependencies = [ [[package]] name = "mmtk-macros" version = "0.27.0" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=fa5327544e2546654a6d89ed5db4509966e89182#fa5327544e2546654a6d89ed5db4509966e89182" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=45cdf31055b1b6a629bdb8032adaa6dd5a8e32b9#45cdf31055b1b6a629bdb8032adaa6dd5a8e32b9" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index c12ffb7..e01026c 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -37,10 +37,10 @@ features = ["is_mmtk_object", "object_pinning", "sticky_immix_non_moving_nursery # Uncomment the following lines to use mmtk-core from the official repository. git = "https://github.com/mmtk/mmtk-core.git" -rev = "fa5327544e2546654a6d89ed5db4509966e89182" +rev = "45cdf31055b1b6a629bdb8032adaa6dd5a8e32b9" # Uncomment the following line to use mmtk-core from a local repository. -# path = "../../mmtk-core" +#path = "../../mmtk-core" [features] default = [] diff --git a/mmtk/src/api.rs b/mmtk/src/api.rs index 8d1c67e..f7d7a6b 100644 --- a/mmtk/src/api.rs +++ b/mmtk/src/api.rs @@ -173,7 +173,7 @@ pub extern "C" fn mmtk_post_alloc( #[no_mangle] pub extern "C" fn mmtk_will_never_move(object: ObjectReference) -> bool { - !object.is_movable::() + !object.is_movable() } #[no_mangle] @@ -224,17 +224,17 @@ pub extern "C" fn mmtk_total_bytes() -> usize { #[no_mangle] pub extern "C" fn mmtk_is_reachable(object: ObjectReference) -> bool { - object.is_reachable::() + object.is_reachable() } #[no_mangle] pub extern "C" fn mmtk_is_live_object(object: ObjectReference) -> bool { - memory_manager::is_live_object::(object) + memory_manager::is_live_object(object) } #[no_mangle] pub extern "C" fn mmtk_get_forwarded_object(object: ObjectReference) -> NullableObjectReference { - object.get_forwarded_object::().into() + object.get_forwarded_object().into() } #[no_mangle] @@ -337,17 +337,17 @@ pub extern "C" fn mmtk_get_immix_bump_ptr_offset() -> usize { #[no_mangle] pub extern "C" fn mmtk_pin_object(object: ObjectReference) -> bool { - mmtk::memory_manager::pin_object::(object) + mmtk::memory_manager::pin_object(object) } #[no_mangle] pub extern "C" fn mmtk_unpin_object(object: ObjectReference) -> bool { - mmtk::memory_manager::unpin_object::(object) + mmtk::memory_manager::unpin_object(object) } #[no_mangle] pub extern "C" fn mmtk_is_pinned(object: ObjectReference) -> bool { - mmtk::memory_manager::is_pinned::(object) + mmtk::memory_manager::is_pinned(object) } #[no_mangle] diff --git a/mmtk/src/object_model.rs b/mmtk/src/object_model.rs index f7dac5c..cee8f3f 100644 --- a/mmtk/src/object_model.rs +++ b/mmtk/src/object_model.rs @@ -120,8 +120,6 @@ impl ObjectModel for VMObjectModel { RubyObjectAccess::from_objref(object).payload_addr() } - const IN_OBJECT_ADDRESS_OFFSET: isize = 0; - fn get_size_when_copied(object: ObjectReference) -> usize { Self::get_current_size(object) } diff --git a/mmtk/src/ppp.rs b/mmtk/src/ppp.rs index 9cab0e7..526089c 100644 --- a/mmtk/src/ppp.rs +++ b/mmtk/src/ppp.rs @@ -75,8 +75,8 @@ impl PPPRegistry { probe!(mmtk_ruby, remove_dead_ppps_start, ppps.len()); ppps.retain_mut(|obj| { - if obj.is_live::() { - *obj = obj.get_forwarded_object::().unwrap_or(*obj); + if obj.is_live() { + *obj = obj.get_forwarded_object().unwrap_or(*obj); true } else { log::trace!(" PPP removed: {}", *obj); @@ -97,7 +97,7 @@ impl PPPRegistry { .expect("PPPRegistry::pinned_ppp_children should not have races during GC."); probe!(mmtk_ruby, unpin_ppp_children_start, pinned_ppps.len()); for obj in pinned_ppps.drain(..) { - let unpinned = memory_manager::unpin_object::(obj); + let unpinned = memory_manager::unpin_object(obj); debug_assert!(unpinned); } probe!(mmtk_ruby, unpin_ppp_children_end); @@ -147,7 +147,7 @@ impl GCWork for PinPPPChildren { }); for target_object in ppp_children { - if memory_manager::pin_object::(target_object) { + if memory_manager::pin_object(target_object) { newly_pinned_ppp_children.push(target_object); } } diff --git a/mmtk/src/scanning.rs b/mmtk/src/scanning.rs index 67daeae..b27dd5d 100644 --- a/mmtk/src/scanning.rs +++ b/mmtk/src/scanning.rs @@ -280,7 +280,7 @@ impl> GCWork for ScanWbUnprotectedRoots { let gc_tls = unsafe { GCThreadTLS::from_vwt_check(worker.tls) }; VMScanning::collect_object_roots_in("wb_unprot_roots", gc_tls, &mut self.factory, || { for object in self.objects.iter().copied() { - if object.is_reachable::() { + if object.is_reachable() { debug!( "[wb_unprot_roots] Visiting WB-unprotected object (parent): {}", object diff --git a/mmtk/src/weak_proc.rs b/mmtk/src/weak_proc.rs index f231a7d..ccaa592 100644 --- a/mmtk/src/weak_proc.rs +++ b/mmtk/src/weak_proc.rs @@ -202,7 +202,7 @@ impl GCWork for ProcessObjFreeCandidates { let mut new_candidates = Vec::new(); for object in obj_free_candidates.iter().copied() { - if object.is_reachable::() { + if object.is_reachable() { // Forward and add back to the candidate list. let new_object = object.forward(); trace!( @@ -230,7 +230,7 @@ trait GlobalTableProcessingWork { // of `trace_object` due to the way it is used in `UPDATE_IF_MOVED`. let forward_object = |_worker, object: ObjectReference, _pin| { debug_assert!( - mmtk::memory_manager::is_mmtk_object(object.to_address::()).is_some(), + mmtk::memory_manager::is_mmtk_object(object.to_raw_address()).is_some(), "{} is not an MMTk object", object ); @@ -352,7 +352,7 @@ impl GCWork for UpdateWbUnprotectedObjectsList { debug!("Updating {} WB-unprotected objects", old_objects.len()); for object in old_objects { - if object.is_reachable::() { + if object.is_reachable() { // Forward and add back to the candidate list. let new_object = object.forward(); trace!( @@ -377,6 +377,6 @@ trait Forwardable { impl Forwardable for ObjectReference { fn forward(&self) -> Self { - self.get_forwarded_object::().unwrap_or(*self) + self.get_forwarded_object().unwrap_or(*self) } }