-
Notifications
You must be signed in to change notification settings - Fork 69
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
Rename is_pinned, pin_object and unpin_object #917
Comments
I think we discussed about the pin bit before. At that point, the idea was that we should not expose the existence of pin bit, but rather provide an abstract pinning semantic. The reason behind it was that we may not actually have a 'pin bit' for some policies. For example, we may use one state in the 2-bit forwarding bits to represent the pinned state. And for non moving policies, they do not even need a pin bit. However, at that point, we did not have 'transitively pin'. So all the discussion was about the normal pinning semantic that pins one object. I think now we just need a term to describe the normal pinning, to differentiate from the transitively pinning. If we use 'pin bit', probably we probably would like to describe it as a 'logical' pin bit, and it does not mean we actually use a 'pin bit'. But that also sounds confusing. My preference is that we find a term to describe the semantic. |
We may consider removing the TL;DR: The user cannot reliably use Problems
Inconsistent semanticsIts semantics is not consistent with the other two API, namely
It makes a different for spaces that never move objects, such as It is tempting for VM bindings to use Time-of-check to time-of-use (TOCTTOU)FYI: https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use In a multi-threaded environment, multiple threads can attempt to pin or unpin objects concurrently. If one thread calls Because of this, Who is responsible for unpinning?How to decide whether any component of the VM binding (a thread, or a step of processing) should unpin an object at a certain stage? A rule of thumb is that whoever called For example, if the VM binding maintains a list of objects to be pinned during GC (for example, children of "potentially pinning parents". See #690), but some objects have already be pinned during mutator phase, the VM binding wants to make sure that after the GC, any objects that have been pinned before GC remain pinned, and any object that were not pinned before GC remain un-pinned. To do this, the VM binding can enumerate objects to be pinned, call |
In the
memory_manager
module, there are functionsis_pinned
,pin_object
andunpin_object
. Those functions operate on the pin bit metadata.One problem with those functions is that those function names give the user an impression that it is "the right way" or "the only way" to pin object. However, with the PR #897, it will no longer be true. The preferred way to pin an object and also keep the object alive is adding those objects into the non-transitively pining root set (previously known as "black" roots). The pinning bits are still useful for pinning objects while not keeping them alive.
We should rename those functions so that it is clear that those functions operate on the "pin bits" metadata.
is_pinned
->keep asis_pin_bit_set
is_pinned
, or removepin_object
->set_pin_bit
set_pinned
unpin_object
->clear_pin_bit
unset_pinned
Since it is an API-breaking change, we can move those functions to the
util::metadata::pin_bit
module and make those functions public in order to make the API idiomatic to Rust (#658).Update: Instead of mentioning "pin bit" in the API, we can tell the user that each object has a "pinned" state which can be set and unset. The state may be implemented as the pin bit (
ObjectModel::LOCAL_PINNING_BIT_SPEC
), but it is a local metadata, and spaces don't necessarily use it.Update: We may consider removing the
is_pinned
function. See comments below.The text was updated successfully, but these errors were encountered: