Skip to content

Commit

Permalink
Move to Rust 1.83
Browse files Browse the repository at this point in the history
  • Loading branch information
qinsoon committed Jan 6, 2025
1 parent 1ef4223 commit 32a83d2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 40 deletions.
8 changes: 4 additions & 4 deletions mmtk/Cargo.lock

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

2 changes: 1 addition & 1 deletion mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ log = "*"
# - change branch
# - change repo name
# But other changes including adding/removing whitespaces in commented lines may break the CI.
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "45cdf31055b1b6a629bdb8032adaa6dd5a8e32b9" }
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "ac80c8de8ac551959839dfaa79e87c1a05a9e89c" }
# Uncomment the following and fix the path to mmtk-core to build locally
# mmtk = { path = "../repos/mmtk-core" }

Expand Down
2 changes: 1 addition & 1 deletion mmtk/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.77.0
1.83.0
6 changes: 0 additions & 6 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ pub extern "C" fn total_bytes(mmtk: &mut MMTK<V8>) -> usize {
memory_manager::total_bytes(&*mmtk)
}

#[no_mangle]
#[cfg(feature = "sanity")]
pub extern "C" fn scan_region(mmtk: &mut MMTK<V8>) {
memory_manager::scan_region(mmtk);
}

#[no_mangle]
pub extern "C" fn is_live_object(object: ObjectReference) -> bool {
memory_manager::is_live_object(object)
Expand Down
59 changes: 31 additions & 28 deletions mmtk/src/object_archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,52 @@ pub extern "C" fn tph_archive_delete(arch: *mut c_void) {
};
}

fn with_archive_raw_pointer<F, R>(arch: *mut c_void, f: F) -> R where F: Fn(&mut ObjectArchive) -> R {
let mut arch = unsafe { Box::from_raw(arch as *mut ObjectArchive) };
let res = f(&mut arch);
let _ = Box::into_raw(arch);
res
}

#[no_mangle]
pub extern "C" fn tph_archive_iter_reset(arch: *mut c_void) {
let mut arch = unsafe { Box::from_raw(arch as *mut ObjectArchive) };
arch.reset_iterator();
Box::into_raw(arch);
with_archive_raw_pointer(arch, |arch| {
arch.reset_iterator();
})
}

#[no_mangle]
pub extern "C" fn tph_archive_iter_next(arch: *mut c_void) -> *mut c_void {
let mut arch = unsafe { Box::from_raw(arch as *mut ObjectArchive) };
let res = arch.next_object();
Box::into_raw(arch);
res.to_mut_ptr()
with_archive_raw_pointer(arch, |arch| {
arch.next_object().to_mut_ptr()
})
}

#[no_mangle]
pub extern "C" fn tph_archive_inner_to_obj(
arch: *mut c_void,
inner_ptr: *mut c_void,
) -> *mut c_void {
let arch = unsafe { Box::from_raw(arch as *mut ObjectArchive) };
let res = arch.inner_addr_to_object(Address::from_mut_ptr(inner_ptr));
Box::into_raw(arch);
res.to_mut_ptr()
with_archive_raw_pointer(arch, |arch| {
arch.inner_addr_to_object(Address::from_mut_ptr(inner_ptr)).to_mut_ptr()
})
}

#[no_mangle]
pub extern "C" fn tph_archive_obj_to_isolate(
arch: *mut c_void,
obj_ptr: *mut c_void,
) -> *mut c_void {
let arch = unsafe { Box::from_raw(arch as *mut ObjectArchive) };
let res = arch.object_to_isolate(Address::from_mut_ptr(obj_ptr));
Box::into_raw(arch);
res.to_mut_ptr()
with_archive_raw_pointer(arch, |arch| {
arch.object_to_isolate(Address::from_mut_ptr(obj_ptr)).to_mut_ptr()
})
}

#[no_mangle]
pub extern "C" fn tph_archive_obj_to_space(arch: *mut c_void, obj_ptr: *mut c_void) -> u8 {
let arch = unsafe { Box::from_raw(arch as *mut ObjectArchive) };
let res = arch.object_to_space(Address::from_mut_ptr(obj_ptr));
Box::into_raw(arch);
res
with_archive_raw_pointer(arch, |arch| {
arch.object_to_space(Address::from_mut_ptr(obj_ptr))
})
}

#[no_mangle]
Expand All @@ -69,19 +72,19 @@ pub extern "C" fn tph_archive_insert(
iso_ptr: *mut c_void,
space: u8,
) {
let obj_addr = Address::from_mut_ptr(obj_ptr);
let iso_addr = Address::from_mut_ptr(iso_ptr);
let mut arch = unsafe { Box::from_raw(arch as *mut ObjectArchive) };
arch.insert_object(obj_addr, iso_addr, space);
Box::into_raw(arch);
with_archive_raw_pointer(arch, |arch| {
let obj_addr = Address::from_mut_ptr(obj_ptr);
let iso_addr = Address::from_mut_ptr(iso_ptr);
arch.insert_object(obj_addr, iso_addr, space);
})
}

#[no_mangle]
pub extern "C" fn tph_archive_remove(arch: *mut c_void, obj_ptr: *mut c_void) {
let obj_addr = Address::from_mut_ptr(obj_ptr);
let mut arch = unsafe { Box::from_raw(arch as *mut ObjectArchive) };
arch.remove_object(obj_addr);
Box::into_raw(arch);
with_archive_raw_pointer(arch, |arch| {
let obj_addr = Address::from_mut_ptr(obj_ptr);
arch.remove_object(obj_addr);
})
}

pub struct ObjectArchive {
Expand Down

0 comments on commit 32a83d2

Please sign in to comment.