Skip to content

Commit

Permalink
Fix GCWorker ownership (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
wks authored Jan 28, 2022
1 parent 1f5d8cb commit e0f5b0c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ lazy_static = "1.1"
# - 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 = "4851e7ac7e8a7bd70ce65935c4ac1ff430cab6f1" }
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "4ebb6b68f54a55bf8794ea01db3f2d0f28d15f4d" }
# Uncomment the following to build locally
# mmtk = { path = "../repos/mmtk-core" }

Expand Down
3 changes: 2 additions & 1 deletion mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ pub extern "C" fn will_never_move(object: ObjectReference) -> bool {
// We trust the worker pointer is valid.
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn start_worker(tls: VMWorkerThread, worker: *mut GCWorker<OpenJDK>) {
memory_manager::start_worker::<OpenJDK>(tls, unsafe { worker.as_mut().unwrap() }, &SINGLETON)
let mut worker = unsafe { Box::from_raw(worker) };
memory_manager::start_worker::<OpenJDK>(tls, &mut worker, &SINGLETON)
}

#[no_mangle]
Expand Down
4 changes: 2 additions & 2 deletions mmtk/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ impl Collection<OpenJDK> for VMCollection {
}
}

fn spawn_worker_thread(tls: VMThread, ctx: Option<&GCWorker<OpenJDK>>) {
fn spawn_worker_thread(tls: VMThread, ctx: Option<Box<GCWorker<OpenJDK>>>) {
let ctx_ptr = if let Some(r) = ctx {
r as *const GCWorker<OpenJDK> as *mut GCWorker<OpenJDK>
Box::into_raw(r)
} else {
std::ptr::null_mut()
};
Expand Down

0 comments on commit e0f5b0c

Please sign in to comment.