-
Notifications
You must be signed in to change notification settings - Fork 68
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
Support MMTk instances #100
Comments
TL;DR: The VM controls the lifetime of I have been thinking about what is the proper way to express the lifetimes of MMTK, Plan and Mutator instances. My current conclusion is that their lifetimes are dynamic, and cannot be statically checked by Rust. More precisely, their lifetimes are controlled by the VM, not by mmtk-core itself. The VM controls the lifetimesCurrently mmtk-core requires the MMTK instance to be static. By doing this, there is no correctness issues now, but when introducing multiple MMTK instances, the lifetime of MMTK, Plan and Mutator become important. In theory, But MMTK is, by nature, controlled by the VM via the API. So the lifetime of MMTK and Plan:
and the lifetime of Mutator:
So if a buggy VM insists on calling the API in the following sequence: MMTk* mmtk = create_mmtk(&config);
MMTk_Mutator* mutator = bind_mutator(tls);
destroy_mmtk(mmtk); // ERROR: mutator is still alive
destroy_mutator(mutator); // too late then the third line This means, Rust's static life-time checker cannot help. We could just use unsafe pointers. However, it is possible to dynamically check the ownership, and We need a
|
For your example code, Rust can static check it: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b0b44fab68cb343b8978f5eb2508b92f |
@qinsoon Yes. This is helpful if the VM itself is written in Rust. But what if the main function in your snippet is written in C++? Of course we can use The code above shows a VM calling into MMTK via a C-style binding. This time, if the VM calls the API functions in the wrong order, it still compiles, but will have runtime error. The code above prints a garbage value, and Valgrind can catch the use-after-free bug. Using
|
Our current |
Set the priority to low. We should raise the priority if we work on any VM that needs this. |
Though we have done some refactoring to allow multiple instances, we currently have no use case of multiple MMTk instances, and it is unclear that we are missing to properly support multiple instances. Porting to V8 could be a good chance to figure this out.
The text was updated successfully, but these errors were encountered: