From 00b5af46fabddb7c3507c041b8f52bd55fba170f Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Mon, 17 Aug 2026 04:53:12 +0000 Subject: [PATCH 1/4] Update for LXR-related API changes --- mmtk/Cargo.lock | 8 +++---- mmtk/Cargo.toml | 4 ++-- mmtk/src/object_model.rs | 51 ++++++++++++++++++++++++++++++++++++++++ mmtk/src/scanning.rs | 4 ++-- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/mmtk/Cargo.lock b/mmtk/Cargo.lock index d11a2f1..c4ad108 100644 --- a/mmtk/Cargo.lock +++ b/mmtk/Cargo.lock @@ -482,8 +482,8 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "mmtk" -version = "0.32.0" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=3e610aa4a16585f0c75e98d1d67ff80be9b9295f#3e610aa4a16585f0c75e98d1d67ff80be9b9295f" +version = "0.33.0" +source = "git+https://github.com/wenyuzhao/mmtk-core.git?rev=6c20851f8f619f84c67a247cfa2d397bcb9b5251#6c20851f8f619f84c67a247cfa2d397bcb9b5251" dependencies = [ "atomic", "atomic-traits", @@ -517,8 +517,8 @@ dependencies = [ [[package]] name = "mmtk-macros" -version = "0.32.0" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=3e610aa4a16585f0c75e98d1d67ff80be9b9295f#3e610aa4a16585f0c75e98d1d67ff80be9b9295f" +version = "0.33.0" +source = "git+https://github.com/wenyuzhao/mmtk-core.git?rev=6c20851f8f619f84c67a247cfa2d397bcb9b5251#6c20851f8f619f84c67a247cfa2d397bcb9b5251" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 4f7347d..6cc73f6 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -36,8 +36,8 @@ probe = "0.5" features = ["vo_bit", "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 = "3e610aa4a16585f0c75e98d1d67ff80be9b9295f" +git = "https://github.com/wenyuzhao/mmtk-core.git" +rev = "6c20851f8f619f84c67a247cfa2d397bcb9b5251" # Uncomment the following line to use mmtk-core from a local repository. #path = "../../mmtk-core" diff --git a/mmtk/src/object_model.rs b/mmtk/src/object_model.rs index 217f057..bda2d4d 100644 --- a/mmtk/src/object_model.rs +++ b/mmtk/src/object_model.rs @@ -16,6 +16,11 @@ impl VMObjectModel { impl ObjectModel for VMObjectModel { const GLOBAL_LOG_BIT_SPEC: VMGlobalLogBitSpec = VMGlobalLogBitSpec::side_first(); + // Only plans that need a field-granularity log bit (e.g. LXR) actually reserve this; + // none of Ruby's current plans use such a plan. + const GLOBAL_FIELD_UNLOG_BIT_SPEC: VMGlobalFieldUnlogBitSpec = + VMGlobalFieldUnlogBitSpec::side_after(Self::GLOBAL_LOG_BIT_SPEC.as_spec()); + // We overwrite the prepended word which were used to hold object sizes. const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec = VMLocalForwardingPointerSpec::in_header(-((OBJREF_OFFSET * BITS_IN_BYTE) as isize)); @@ -81,6 +86,52 @@ impl ObjectModel for VMObjectModel { to_obj } + fn try_copy( + from: ObjectReference, + semantics: CopySemantics, + copy_context: &mut GCWorkerCopyContext, + ) -> Option { + let from_acc = RubyObjectAccess::from_objref(from); + let has_exivar = from_acc.has_exivar(); + 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); + if to_start.is_zero() { + return None; + } + let to_payload = to_start.add(OBJREF_OFFSET); + unsafe { + copy_nonoverlapping::(from_start.to_ptr(), to_start.to_mut_ptr(), object_size); + } + // 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); + + #[cfg(feature = "clear_old_copy")] + { + trace!( + "Clearing old copy {} ({}-{})", + from, + from_start, + from_start + object_size + ); + // For debug purpose, we clear the old copy so that if the Ruby VM reads from the old + // copy again, it will likely result in an error. + unsafe { std::ptr::write_bytes::(from_start.to_mut_ptr(), 0, object_size) } + } + + if has_exivar { + let mut backwarding_table = crate::binding().backwarding_table.lock().unwrap(); + trace!("Inserting into backwarding table: from: {from} <- to_obj: {to_obj}"); + backwarding_table.insert(to_obj, from); + } else { + trace!("No exivar: from: {from} <- to_obj: {to_obj}"); + } + + Some(to_obj) + } + fn copy_to(_from: ObjectReference, _to: ObjectReference, _region: Address) -> Address { unimplemented!( "This function cannot be called because we do not support MarkCompact for Ruby." diff --git a/mmtk/src/scanning.rs b/mmtk/src/scanning.rs index 0848cec..1102a20 100644 --- a/mmtk/src/scanning.rs +++ b/mmtk/src/scanning.rs @@ -19,10 +19,10 @@ impl Scanning for VMScanning { false } - fn scan_object>( + fn scan_object( _tls: VMWorkerThread, _object: ObjectReference, - _slot_visitor: &mut EV, + _slot_visitor: &mut impl SlotVisitor, ) { unreachable!("We have not enabled slot enqueuing for any types, yet."); } From 9e2daf74885a201e99aef46cdf2421ecb39a0490 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Mon, 17 Aug 2026 05:28:56 +0000 Subject: [PATCH 2/4] Update mmtk-core --- mmtk/Cargo.lock | 4 ++-- mmtk/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mmtk/Cargo.lock b/mmtk/Cargo.lock index c4ad108..3c5db6a 100644 --- a/mmtk/Cargo.lock +++ b/mmtk/Cargo.lock @@ -483,7 +483,7 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "mmtk" version = "0.33.0" -source = "git+https://github.com/wenyuzhao/mmtk-core.git?rev=6c20851f8f619f84c67a247cfa2d397bcb9b5251#6c20851f8f619f84c67a247cfa2d397bcb9b5251" +source = "git+https://github.com/wenyuzhao/mmtk-core.git?rev=6d7566fc56ad2a98a6760adaa4915f39a5e0c580#6d7566fc56ad2a98a6760adaa4915f39a5e0c580" dependencies = [ "atomic", "atomic-traits", @@ -518,7 +518,7 @@ dependencies = [ [[package]] name = "mmtk-macros" version = "0.33.0" -source = "git+https://github.com/wenyuzhao/mmtk-core.git?rev=6c20851f8f619f84c67a247cfa2d397bcb9b5251#6c20851f8f619f84c67a247cfa2d397bcb9b5251" +source = "git+https://github.com/wenyuzhao/mmtk-core.git?rev=6d7566fc56ad2a98a6760adaa4915f39a5e0c580#6d7566fc56ad2a98a6760adaa4915f39a5e0c580" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 6cc73f6..9635584 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -37,7 +37,7 @@ features = ["vo_bit", "object_pinning", "sticky_immix_non_moving_nursery"] # Uncomment the following lines to use mmtk-core from the official repository. git = "https://github.com/wenyuzhao/mmtk-core.git" -rev = "6c20851f8f619f84c67a247cfa2d397bcb9b5251" +rev = "6d7566fc56ad2a98a6760adaa4915f39a5e0c580" # Uncomment the following line to use mmtk-core from a local repository. #path = "../../mmtk-core" From cd0a2ddcf5f5bc6ea19a8846a5a562d6edfbee24 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Mon, 17 Aug 2026 06:23:20 +0000 Subject: [PATCH 3/4] Update mmtk-core --- mmtk/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 9635584..044c77d 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -37,7 +37,7 @@ features = ["vo_bit", "object_pinning", "sticky_immix_non_moving_nursery"] # Uncomment the following lines to use mmtk-core from the official repository. git = "https://github.com/wenyuzhao/mmtk-core.git" -rev = "6d7566fc56ad2a98a6760adaa4915f39a5e0c580" +rev = "cb457dd5af014a571c82a44b90ca7a9b60ac7310" # Uncomment the following line to use mmtk-core from a local repository. #path = "../../mmtk-core" From a40c3c9b90a9c1b693deaa78307c5494ba2d50b9 Mon Sep 17 00:00:00 2001 From: mmtkgc-bot Date: Wed, 19 Aug 2026 10:59:35 +0000 Subject: [PATCH 4/4] Update mmtk-core to 2feeaccb130d95376e248b0aee6bf8f83c56f0ea --- mmtk/Cargo.lock | 4 ++-- mmtk/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mmtk/Cargo.lock b/mmtk/Cargo.lock index 3c5db6a..22537a7 100644 --- a/mmtk/Cargo.lock +++ b/mmtk/Cargo.lock @@ -483,7 +483,7 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "mmtk" version = "0.33.0" -source = "git+https://github.com/wenyuzhao/mmtk-core.git?rev=6d7566fc56ad2a98a6760adaa4915f39a5e0c580#6d7566fc56ad2a98a6760adaa4915f39a5e0c580" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=2feeaccb130d95376e248b0aee6bf8f83c56f0ea#2feeaccb130d95376e248b0aee6bf8f83c56f0ea" dependencies = [ "atomic", "atomic-traits", @@ -518,7 +518,7 @@ dependencies = [ [[package]] name = "mmtk-macros" version = "0.33.0" -source = "git+https://github.com/wenyuzhao/mmtk-core.git?rev=6d7566fc56ad2a98a6760adaa4915f39a5e0c580#6d7566fc56ad2a98a6760adaa4915f39a5e0c580" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=2feeaccb130d95376e248b0aee6bf8f83c56f0ea#2feeaccb130d95376e248b0aee6bf8f83c56f0ea" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 044c77d..520cdea 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -36,8 +36,8 @@ probe = "0.5" features = ["vo_bit", "object_pinning", "sticky_immix_non_moving_nursery"] # Uncomment the following lines to use mmtk-core from the official repository. -git = "https://github.com/wenyuzhao/mmtk-core.git" -rev = "cb457dd5af014a571c82a44b90ca7a9b60ac7310" +git = "https://github.com/mmtk/mmtk-core.git" +rev = "2feeaccb130d95376e248b0aee6bf8f83c56f0ea" # Uncomment the following line to use mmtk-core from a local repository. #path = "../../mmtk-core"