diff --git a/jikesrvm/rvm/src/org/jikesrvm/VMExt.java b/jikesrvm/rvm/src/org/jikesrvm/VMExt.java new file mode 100644 index 00000000..8de7ad5b --- /dev/null +++ b/jikesrvm/rvm/src/org/jikesrvm/VMExt.java @@ -0,0 +1,20 @@ +package org.jikesrvm; + +import org.jikesrvm.scheduler.RVMThread; +import org.vmmagic.pragma.Entrypoint; + +public class VMExt { + @Entrypoint + public static int enterVM() { + RVMThread cur = RVMThread.getCurrentThread(); + int old = cur.getExecStatus(); + cur.setExecStatus(RVMThread.IN_JAVA); + return old; + } + + @Entrypoint + public static void leaveVM(int status) { + RVMThread cur = RVMThread.getCurrentThread(); + cur.setExecStatus(status); + } +} diff --git a/jikesrvm/rvm/src/org/jikesrvm/runtime/Entrypoints.java b/jikesrvm/rvm/src/org/jikesrvm/runtime/Entrypoints.java index 0e7d4489..78fba419 100644 --- a/jikesrvm/rvm/src/org/jikesrvm/runtime/Entrypoints.java +++ b/jikesrvm/rvm/src/org/jikesrvm/runtime/Entrypoints.java @@ -32,6 +32,10 @@ public class Entrypoints { "(Lorg/jikesrvm/scheduler/RVMThread;Lorg/vmmagic/unboxed/Address;ZZ)V"); public static final NormalMethod scanBootImageMethod = getMethod(org.jikesrvm.mm.mminterface.RustScanning.class, "scanBootImage", "(Lorg/vmmagic/unboxed/Address;)V"); + public static final NormalMethod enterVMMethod = + getMethod(org.jikesrvm.VMExt.class, "enterVM", "()I"); + public static final NormalMethod leaveVMMethod = + getMethod(org.jikesrvm.VMExt.class, "leaveVM", "(I)V"); // The usual causes for getField/Method() to fail are: // 1. you misspelled the class name, member name, or member signature diff --git a/mmtk/src/api.rs b/mmtk/src/api.rs index f8ba8c5b..1c236efb 100644 --- a/mmtk/src/api.rs +++ b/mmtk/src/api.rs @@ -159,13 +159,25 @@ pub extern "C" fn add_phantom_candidate(reff: ObjectReference, referent: ObjectR } #[no_mangle] -pub extern "C" fn harness_begin(tls: OpaquePointer) { - memory_manager::harness_begin(&SINGLETON, tls) +pub extern "C" fn harness_begin(id: usize) { + unsafe { + let thread_from_id = VMCollection::thread_from_id(id); + let tls = OpaquePointer::from_address(thread_from_id); + let st = JikesRVM::enter_vm(tls); + memory_manager::harness_begin(&SINGLETON, tls); + JikesRVM::leave_vm(tls, st); + } } #[no_mangle] -pub extern "C" fn harness_end(tls: OpaquePointer) { - memory_manager::harness_end(&SINGLETON) +pub extern "C" fn harness_end(id: usize) { + unsafe { + let thread_from_id = VMCollection::thread_from_id(id); + let tls = OpaquePointer::from_address(thread_from_id); + let st = JikesRVM::enter_vm(tls); + memory_manager::harness_end(&SINGLETON); + JikesRVM::leave_vm(tls, st); + } } #[no_mangle] diff --git a/mmtk/src/lib.rs b/mmtk/src/lib.rs index d205ae75..1ca45eb6 100644 --- a/mmtk/src/lib.rs +++ b/mmtk/src/lib.rs @@ -8,6 +8,7 @@ extern crate lazy_static; extern crate log; use mmtk::util::address::Address; +use mmtk::util::OpaquePointer; use mmtk::TraceLocal; use mmtk::vm::VMBinding; use mmtk::MMTK; @@ -77,6 +78,18 @@ impl JikesRVM { jtoc_call!(TEST3_METHOD_OFFSET, BOOT_THREAD, input1, input2, input3, input4) } } + + pub fn enter_vm(tls: OpaquePointer) -> i32 { + unsafe { + jtoc_call!(ENTER_VM_METHOD_OFFSET, tls) as i32 + } + } + + pub fn leave_vm(tls: OpaquePointer, status: i32) { + unsafe { + jtoc_call!(LEAVE_VM_METHOD_OFFSET, tls, status); + } + } } lazy_static! { diff --git a/repos/jikesrvm b/repos/jikesrvm index 67dadebb..c4b7938d 160000 --- a/repos/jikesrvm +++ b/repos/jikesrvm @@ -1 +1 @@ -Subproject commit 67dadebb060ed48687dabf7e30805ee70a810686 +Subproject commit c4b7938d0d2cddd9ea5021941fd0a7eaa49dbf76