Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require ObjectReference to point inside object #100

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mmtk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ probe = "0.5"
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"
git = "https://github.com/wks/mmtk-core.git"
rev = "57a98749ff37093b355d7b2f496b8a67315e158b"

# Uncomment the following line to use mmtk-core from a local repository.
# path = "../../mmtk-core"
#path = "../../mmtk-core"

[features]
default = []
Expand Down
14 changes: 7 additions & 7 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Ruby>()
!object.is_movable()
}

#[no_mangle]
Expand Down Expand Up @@ -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::<Ruby>()
object.is_reachable()
}

#[no_mangle]
pub extern "C" fn mmtk_is_live_object(object: ObjectReference) -> bool {
memory_manager::is_live_object::<Ruby>(object)
memory_manager::is_live_object(object)
}

#[no_mangle]
pub extern "C" fn mmtk_get_forwarded_object(object: ObjectReference) -> NullableObjectReference {
object.get_forwarded_object::<Ruby>().into()
object.get_forwarded_object().into()
}

#[no_mangle]
Expand Down Expand Up @@ -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::<Ruby>(object)
mmtk::memory_manager::pin_object(object)
}

#[no_mangle]
pub extern "C" fn mmtk_unpin_object(object: ObjectReference) -> bool {
mmtk::memory_manager::unpin_object::<Ruby>(object)
mmtk::memory_manager::unpin_object(object)
}

#[no_mangle]
pub extern "C" fn mmtk_is_pinned(object: ObjectReference) -> bool {
mmtk::memory_manager::is_pinned::<Ruby>(object)
mmtk::memory_manager::is_pinned(object)
}

#[no_mangle]
Expand Down
2 changes: 0 additions & 2 deletions mmtk/src/object_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ impl ObjectModel<Ruby> 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)
}
Expand Down
8 changes: 4 additions & 4 deletions mmtk/src/ppp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ impl PPPRegistry {

probe!(mmtk_ruby, remove_dead_ppps_start, ppps.len());
ppps.retain_mut(|obj| {
if obj.is_live::<Ruby>() {
*obj = obj.get_forwarded_object::<Ruby>().unwrap_or(*obj);
if obj.is_live() {
*obj = obj.get_forwarded_object().unwrap_or(*obj);
true
} else {
log::trace!(" PPP removed: {}", *obj);
Expand All @@ -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::<Ruby>(obj);
let unpinned = memory_manager::unpin_object(obj);
debug_assert!(unpinned);
}
probe!(mmtk_ruby, unpin_ppp_children_end);
Expand Down Expand Up @@ -147,7 +147,7 @@ impl GCWork<Ruby> for PinPPPChildren {
});

for target_object in ppp_children {
if memory_manager::pin_object::<Ruby>(target_object) {
if memory_manager::pin_object(target_object) {
newly_pinned_ppp_children.push(target_object);
}
}
Expand Down
2 changes: 1 addition & 1 deletion mmtk/src/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<F: RootsWorkFactory<RubySlot>> GCWork<Ruby> for ScanWbUnprotectedRoots<F> {
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::<Ruby>() {
if object.is_reachable() {
debug!(
"[wb_unprot_roots] Visiting WB-unprotected object (parent): {}",
object
Expand Down
8 changes: 4 additions & 4 deletions mmtk/src/weak_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl GCWork<Ruby> for ProcessObjFreeCandidates {
let mut new_candidates = Vec::new();

for object in obj_free_candidates.iter().copied() {
if object.is_reachable::<Ruby>() {
if object.is_reachable() {
// Forward and add back to the candidate list.
let new_object = object.forward();
trace!(
Expand Down Expand Up @@ -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::<Ruby>()).is_some(),
mmtk::memory_manager::is_mmtk_object(object.to_raw_address()).is_some(),
"{} is not an MMTk object",
object
);
Expand Down Expand Up @@ -352,7 +352,7 @@ impl GCWork<Ruby> for UpdateWbUnprotectedObjectsList {
debug!("Updating {} WB-unprotected objects", old_objects.len());

for object in old_objects {
if object.is_reachable::<Ruby>() {
if object.is_reachable() {
// Forward and add back to the candidate list.
let new_object = object.forward();
trace!(
Expand All @@ -377,6 +377,6 @@ trait Forwardable {

impl Forwardable for ObjectReference {
fn forward(&self) -> Self {
self.get_forwarded_object::<Ruby>().unwrap_or(*self)
self.get_forwarded_object().unwrap_or(*self)
}
}