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

Harness hook #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Harness hook #21

wants to merge 3 commits into from

Conversation

qinsoon
Copy link
Member

@qinsoon qinsoon commented Jul 28, 2020

This PR adds proper code so the harness hooks can be invoked by the Rust MMTk probe (https://github.com/mmtk/ci-perf-kit/tree/master/probes/rust_mmtk).

  • harness_begin()/end() takes the current thread ID as an argument to identify the current thread.
    • Though MMTk's harness_begin()/end() takes tls as an argument, tls is VM specific and we cannot get it from the probe code (application code).
  • The binding's harness_begin()/end() is invoked during executing JNI code (IN_JNI), but inside MMTk's harness_begin(), MMTk will invoke some VM code such as blockForGC(). There are multiple assertions to check if the thread is in a proper state. We need to make sure the thread invoking harness_begin()/end() is set to in a proper state.
    • Added enter_vm()/leave_vm() to set the thread status to IN_JAVA, and set it back.
    • Call enter_vm() before calling harness_begin()/end() into MMTk, and call leave_vm() after returning from MMTk.
  • Update JikesRVM's revision (the new revision exposes RVMThread.setExecStatus() as public)

@qinsoon qinsoon requested a review from caizixian July 28, 2020 07:11
Copy link
Member

@caizixian caizixian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jikesrvm_harness_begin:
Now both harness_begin and harness_end are reentrent, the glue code needs to be updated

memory_manager::harness_begin(&SINGLETON, tls)
pub extern "C" fn harness_begin(id: usize) {
unsafe {
let thread_from_id = VMCollection::thread_from_id(id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the application know thread IDs, which are internal to the VM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the ID from Thread.getId(), which is an application level ID.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm, the application level thread ID Thread.getID() is the same as RVMThread.getCurrentThread().getJavaLangThread().getId().
But VMCollection::thread_from_id expects VMThread.getCurrentThread().threadSlot.
Is there any guarantee/code/documentation that suggests they are the same?

@qinsoon
Copy link
Member Author

qinsoon commented Aug 28, 2020

jikesrvm_harness_begin:

Now both harness_begin and harness_end are reentrent, the glue code needs to be updated

Can you be more specific?

@caizixian
Copy link
Member

jikesrvm_harness_begin:

Now both harness_begin and harness_end are reentrent, the glue code needs to be updated

Can you be more specific?

Any Rust code callable from Java (either implicitly due to allocation, or explicitly due to user requested GC, harness begin, etc.) that may call into Java needs to be wrapper in some glue code written in assembly. See https://gitlab.anu.edu.au/mmtk/jikesrvm/-/issues/39 for details.
By the way, we should migrate some issues for JikesRVM over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants