pub(super) struct LocationState {
initialized: bool,
permission: Permission,
idempotent_foreign_access: IdempotentForeignAccess,
}
Expand description
Data for a single location.
Fields§
§initialized: bool
A location is initialized when it is child-accessed for the first time (and the initial
retag initializes the location for the range covered by the type), and it then stays
initialized forever.
For initialized locations, “permission” is the current permission. However, for
uninitialized locations, we still need to track the “future initial permission”: this will
start out to be default_initial_perm
, but foreign accesses need to be taken into account.
Crucially however, while transitions to Disabled
would usually be UB if this location is
protected, that is not the case for uninitialized locations. Instead we just have a latent
“future initial permission” of Disabled
, causing UB only if an access is ever actually
performed.
Note that the tree root is also always initialized, as if the allocation was a write access.
permission: Permission
This pointer’s current permission / future initial permission.
idempotent_foreign_access: IdempotentForeignAccess
See foreign_access_skipping.rs
.
Stores an idempotent foreign access for this location and its children.
For correctness, this must not be too strong, and the recorded idempotent foreign access
of all children must be at least as strong as this. For performance, it should be as strong as possible.
Implementations§
Source§impl LocationState
impl LocationState
Sourcefn new_uninit(permission: Permission, sifa: IdempotentForeignAccess) -> Self
fn new_uninit(permission: Permission, sifa: IdempotentForeignAccess) -> Self
Constructs a new initial state. It has neither been accessed, nor been subjected
to any foreign access yet.
The permission is not allowed to be Active
.
sifa
is the (strongest) idempotent foreign access, see foreign_access_skipping.rs
Sourcefn new_init(permission: Permission, sifa: IdempotentForeignAccess) -> Self
fn new_init(permission: Permission, sifa: IdempotentForeignAccess) -> Self
Constructs a new initial state. It has not yet been subjected
to any foreign access. However, it is already marked as having been accessed.
sifa
is the (strongest) idempotent foreign access, see foreign_access_skipping.rs
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the location has been initialized, i.e. if it has ever been accessed through a child pointer.
Sourcepub fn is_initial(&self) -> bool
pub fn is_initial(&self) -> bool
Check if the state can exist as the initial permission of a pointer.
Do not confuse with is_initialized
, the two are almost orthogonal
as apart from Active
which is not initial and must be initialized,
any other permission can have an arbitrary combination of being
initial/initialized.
FIXME: when the corresponding assert
in tree_borrows/mod.rs
finally
passes and can be uncommented, remove this #[allow(dead_code)]
.
pub fn permission(&self) -> Permission
Sourcefn perform_access(
&mut self,
access_kind: AccessKind,
rel_pos: AccessRelatedness,
protected: bool,
) -> Result<PermTransition, TransitionError>
fn perform_access( &mut self, access_kind: AccessKind, rel_pos: AccessRelatedness, protected: bool, ) -> Result<PermTransition, TransitionError>
Apply the effect of an access to one location, including
- applying
Permission::perform_access
to the innerPermission
, - emitting protector UB if the location is initialized,
- updating the initialized status (child accesses produce initialized locations).
Sourcefn skip_if_known_noop(
&self,
access_kind: AccessKind,
rel_pos: AccessRelatedness,
) -> ContinueTraversal
fn skip_if_known_noop( &self, access_kind: AccessKind, rel_pos: AccessRelatedness, ) -> ContinueTraversal
Tree traversal optimizations. See foreign_access_skipping.rs
.
This checks if such a foreign access can be skipped.
Sourcefn record_new_access(
&mut self,
access_kind: AccessKind,
rel_pos: AccessRelatedness,
)
fn record_new_access( &mut self, access_kind: AccessKind, rel_pos: AccessRelatedness, )
Records a new access, so that future access can potentially be skipped
by skip_if_known_noop
. This must be called on child accesses, and otherwise
shoud be called on foreign accesses for increased performance. It should not be called
when skip_if_known_noop
indicated skipping, since it then is a no-op.
See foreign_access_skipping.rs
Trait Implementations§
Source§impl Clone for LocationState
impl Clone for LocationState
Source§fn clone(&self) -> LocationState
fn clone(&self) -> LocationState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LocationState
impl Debug for LocationState
Source§impl Display for LocationState
impl Display for LocationState
Source§impl Hash for LocationState
impl Hash for LocationState
Source§impl PartialEq for LocationState
impl PartialEq for LocationState
impl Copy for LocationState
impl Eq for LocationState
impl StructuralPartialEq for LocationState
Auto Trait Implementations§
impl Freeze for LocationState
impl RefUnwindSafe for LocationState
impl Send for LocationState
impl Sync for LocationState
impl Unpin for LocationState
impl UnwindSafe for LocationState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 3 bytes