Skip to content

Commit e0f5b0c

Browse files
authored
Fix GCWorker ownership (#134)
1 parent 1f5d8cb commit e0f5b0c

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

mmtk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ lazy_static = "1.1"
2020
# - change branch
2121
# - change repo name
2222
# But other changes including adding/removing whitespaces in commented lines may break the CI.
23-
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "4851e7ac7e8a7bd70ce65935c4ac1ff430cab6f1" }
23+
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "4ebb6b68f54a55bf8794ea01db3f2d0f28d15f4d" }
2424
# Uncomment the following to build locally
2525
# mmtk = { path = "../repos/mmtk-core" }
2626

mmtk/src/api.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ pub extern "C" fn will_never_move(object: ObjectReference) -> bool {
120120
// We trust the worker pointer is valid.
121121
#[allow(clippy::not_unsafe_ptr_arg_deref)]
122122
pub extern "C" fn start_worker(tls: VMWorkerThread, worker: *mut GCWorker<OpenJDK>) {
123-
memory_manager::start_worker::<OpenJDK>(tls, unsafe { worker.as_mut().unwrap() }, &SINGLETON)
123+
let mut worker = unsafe { Box::from_raw(worker) };
124+
memory_manager::start_worker::<OpenJDK>(tls, &mut worker, &SINGLETON)
124125
}
125126

126127
#[no_mangle]

mmtk/src/collection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ impl Collection<OpenJDK> for VMCollection {
4949
}
5050
}
5151

52-
fn spawn_worker_thread(tls: VMThread, ctx: Option<&GCWorker<OpenJDK>>) {
52+
fn spawn_worker_thread(tls: VMThread, ctx: Option<Box<GCWorker<OpenJDK>>>) {
5353
let ctx_ptr = if let Some(r) = ctx {
54-
r as *const GCWorker<OpenJDK> as *mut GCWorker<OpenJDK>
54+
Box::into_raw(r)
5555
} else {
5656
std::ptr::null_mut()
5757
};

0 commit comments

Comments
 (0)