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

Remove coordinator thread #159

Merged
merged 8 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ public final class CollectorThread extends SystemThread {

@Entrypoint
private Address workerInstance = Address.zero();
private boolean isController;

public void setWorker(Address worker, boolean isController) {
public void setWorker(Address worker) {
rvmThread.assertIsRustMMTkCollector();
this.workerInstance = worker;
this.isController = isController;
}

/** used by collector threads to hold state during stack scanning */
Expand Down Expand Up @@ -99,11 +97,7 @@ public CollectorThread(byte[] stack, CollectorContext context) {
@Unpreemptible
public void run() {
if (VM.BuildWithRustMMTk) {
if (this.isController) {
sysCall.sysStartControlCollector(Magic.objectAsAddress(rvmThread), workerInstance);
} else {
sysCall.sysStartWorker(Magic.objectAsAddress(rvmThread), workerInstance);
}
sysCall.sysStartWorker(Magic.objectAsAddress(rvmThread), workerInstance);
} else {
rvmThread.collectorContext.run();
}
Expand Down
2 changes: 1 addition & 1 deletion jikesrvm/rvm/src/org/jikesrvm/runtime/Entrypoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public class Entrypoints {
"(Lorg/vmmagic/unboxed/ObjectReference;)V");
public static final NormalMethod spawnCollectorThreadMethod =
getMethod(org.jikesrvm.mm.mminterface.MemoryManager.class, "spawnCollectorThread",
"(Lorg/vmmagic/unboxed/Address;Z)V");
"(Lorg/vmmagic/unboxed/Address;)V");
public static final NormalMethod outOfMemoryMethod =
getMethod(org.jikesrvm.mm.mminterface.MemoryManager.class, "outOfMemory",
"()V");
Expand Down
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.

4 changes: 2 additions & 2 deletions mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lto = true
[package.metadata.jikesrvm]
# Our CI matches the following line and extract mmtk/jikesrvm. If this line is updated, please check ci yaml files and make sure it works.
jikesrvm_repo = "https://github.com/mmtk/jikesrvm.git"
jikesrvm_version = "259ffacf23d414686bae3ecf843e65d25dfc376e"
jikesrvm_version = "a43efe4f33a6a69aabeb03e5c5e2e8880f96f047"

[dependencies]
libc = "0.2"
Expand All @@ -28,7 +28,7 @@ log = {version = "0.4", features = ["max_level_trace", "release_max_level_off"]
# - change branch/rev
# - 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 = "86518d2ebc34b443c312de017dc81c7b097e3b10" }
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "5ab62f96c006475285b00b6d20a8b1bf83b74a4d" }
# Uncomment the following to build locally - if you change the path locally, do not commit the change in a PR
# mmtk = { path = "../repos/mmtk-core" }

Expand Down
3 changes: 1 addition & 2 deletions mmtk/api/mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ extern bool process(char* name, char* value);
extern void scan_region();
extern void handle_user_collection_request(void *tls);

extern void start_control_collector(void *tls, void* controller);
extern void start_worker(void *tls, void* worker);

extern void release_buffer(void* buffer);
Expand Down Expand Up @@ -113,4 +112,4 @@ extern void harness_end();
}
#endif

#endif // MMTK_H
#endif // MMTK_H
20 changes: 2 additions & 18 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,16 @@ pub extern "C" fn will_never_move(object: ObjectReference) -> i32 {
!object.is_movable() as i32
}

#[no_mangle]
// We trust the gc_collector pointer is valid.
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn start_control_collector(
tls: VMWorkerThread,
gc_controller: *mut GCController<JikesRVM>,
) {
let mut gc_controller = unsafe { Box::from_raw(gc_controller) };
let cstr = std::ffi::CString::new("MMTkController").unwrap();
unsafe {
libc::pthread_setname_np(libc::pthread_self(), cstr.as_ptr());
}

memory_manager::start_control_collector(&SINGLETON, tls, &mut gc_controller);
}

#[no_mangle]
// 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<JikesRVM>) {
let mut worker = unsafe { Box::from_raw(worker) };
let worker = unsafe { Box::from_raw(worker) };
let cstr = std::ffi::CString::new(format!("MMTkWorker{}", worker.ordinal)).unwrap();
unsafe {
libc::pthread_setname_np(libc::pthread_self(), cstr.as_ptr());
}
memory_manager::start_worker::<JikesRVM>(&SINGLETON, tls, &mut worker)
memory_manager::start_worker::<JikesRVM>(&SINGLETON, tls, worker)
}

#[no_mangle]
Expand Down
12 changes: 3 additions & 9 deletions mmtk/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,11 @@ impl Collection<JikesRVM> for VMCollection {
}

fn spawn_gc_thread(tls: VMThread, ctx: GCThreadContext<JikesRVM>) {
let (ctx_ptr, is_controller) = match ctx {
GCThreadContext::Controller(c) => (Box::into_raw(c) as *mut libc::c_void, 1),
GCThreadContext::Worker(c) => (Box::into_raw(c) as *mut libc::c_void, 0),
let ctx_ptr = match ctx {
GCThreadContext::Worker(c) => Box::into_raw(c),
};
unsafe {
jtoc_call!(
SPAWN_COLLECTOR_THREAD_METHOD_OFFSET,
tls,
ctx_ptr,
is_controller
);
jtoc_call!(SPAWN_COLLECTOR_THREAD_METHOD_OFFSET, tls, ctx_ptr);
}
}

Expand Down
Loading