diff --git a/mmtk/Cargo.lock b/mmtk/Cargo.lock index 9206cc0..c550d81 100644 --- a/mmtk/Cargo.lock +++ b/mmtk/Cargo.lock @@ -425,7 +425,7 @@ dependencies = [ [[package]] name = "mmtk" version = "0.24.0" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=5a01555b5aee984b634f81e9d137f1ae0410fd39#5a01555b5aee984b634f81e9d137f1ae0410fd39" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=6aa75cd72247d12b9568dc321c46feca6572a512#6aa75cd72247d12b9568dc321c46feca6572a512" dependencies = [ "atomic", "atomic-traits", @@ -460,7 +460,7 @@ dependencies = [ [[package]] name = "mmtk-macros" version = "0.24.0" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=5a01555b5aee984b634f81e9d137f1ae0410fd39#5a01555b5aee984b634f81e9d137f1ae0410fd39" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=6aa75cd72247d12b9568dc321c46feca6572a512#6aa75cd72247d12b9568dc321c46feca6572a512" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 2484c39..ab68444 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -37,10 +37,10 @@ features = ["is_mmtk_object", "object_pinning"] # Uncomment the following lines to use mmtk-core from the official repository. git = "https://github.com/mmtk/mmtk-core.git" -rev = "5a01555b5aee984b634f81e9d137f1ae0410fd39" +rev = "6aa75cd72247d12b9568dc321c46feca6572a512" # 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 0a8303b..93b593a 100644 --- a/mmtk/src/api.rs +++ b/mmtk/src/api.rs @@ -17,6 +17,7 @@ use mmtk::memory_manager; use mmtk::memory_manager::mmtk_init; use mmtk::util::alloc::AllocatorInfo; use mmtk::util::alloc::AllocatorSelector; +use mmtk::util::apiutils::NullableObjectReference; use mmtk::util::constants::MIN_OBJECT_SIZE; use mmtk::util::options::GCTriggerSelector; use mmtk::util::options::PlanSelector; @@ -208,10 +209,8 @@ pub extern "C" fn mmtk_is_live_object(object: ObjectReference) -> bool { } #[no_mangle] -pub extern "C" fn mmtk_get_forwarded_object(object: ObjectReference) -> ObjectReference { - object - .get_forwarded_object::() - .unwrap_or(ObjectReference::NULL) +pub extern "C" fn mmtk_get_forwarded_object(object: ObjectReference) -> NullableObjectReference { + object.get_forwarded_object::().into() } #[no_mangle] diff --git a/mmtk/src/object_model.rs b/mmtk/src/object_model.rs index 2ff1e11..e8c581e 100644 --- a/mmtk/src/object_model.rs +++ b/mmtk/src/object_model.rs @@ -51,11 +51,13 @@ impl ObjectModel for VMObjectModel { let from_start = from_acc.obj_start(); let object_size = from_acc.object_size(); let to_start = copy_context.alloc_copy(from, object_size, MIN_OBJ_ALIGN, 0, semantics); + debug_assert!(!to_start.is_zero()); let to_payload = to_start.add(OBJREF_OFFSET); unsafe { copy_nonoverlapping::(from_start.to_ptr(), to_start.to_mut_ptr(), object_size); } - let to_obj = ObjectReference::from_raw_address(to_payload); + // unsafe: `to_payload`` cannot be zero because `alloc_copy`` never returns zero. + let to_obj = unsafe { ObjectReference::from_raw_address_unchecked(to_payload) }; copy_context.post_copy(to_obj, object_size, semantics); trace!("Copied object from {} to {}", from, to_obj); @@ -123,7 +125,8 @@ impl ObjectModel for VMObjectModel { } fn address_to_ref(addr: Address) -> ObjectReference { - ObjectReference::from_raw_address(addr) + debug_assert!(!addr.is_zero()); + unsafe { ObjectReference::from_raw_address_unchecked(addr) } } fn get_size_when_copied(object: ObjectReference) -> usize { diff --git a/mmtk/src/reference_glue.rs b/mmtk/src/reference_glue.rs index 5cf8593..1272bd5 100644 --- a/mmtk/src/reference_glue.rs +++ b/mmtk/src/reference_glue.rs @@ -8,7 +8,7 @@ pub struct VMReferenceGlue {} impl ReferenceGlue for VMReferenceGlue { type FinalizableType = ObjectReference; - fn get_referent(_object: ObjectReference) -> ObjectReference { + fn get_referent(_object: ObjectReference) -> Option { unimplemented!() } @@ -19,4 +19,8 @@ impl ReferenceGlue for VMReferenceGlue { fn enqueue_references(_references: &[ObjectReference], _tls: VMWorkerThread) { unimplemented!() } + + fn clear_referent(_new_reference: ObjectReference) { + unimplemented!() + } }