-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[2/n][vm-rewrite][Move] Update runtime value representation to support global references. #21066
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
[2/n][vm-rewrite][Move] Update runtime value representation to support global references. #21066
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
external-crates/move/crates/move-vm-runtime/src/execution/values/values_impl.rs
Outdated
Show resolved
Hide resolved
30e5561
to
dbf5e6d
Compare
c07295c
to
1c7a767
Compare
// XXX/TODO(vm-rewrite): Remove this and replace with proper value dirtying. | ||
#[derive(Debug)] | ||
pub struct FixedSizeVec(Box<[Value]>); | ||
pub struct GlobalFingerprint(Option<String>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a deprecated
note here so we remember to come back and fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as a "quick and dirty hack" toward code completeness, with the understanding that we will fix it later.
…t global references. This updates the VM value representation to support global values, and "fingerprinting" of the global values so that they can be properly dirtied at the end of execution. **IMPORTANT**: Additional work is needed to make the fingerprinting of global values actually something we'd want to use in prod, but the underlying logic of what a fingerprint is, and how it is computed has been abstracted away into a newtype so we can update this fairly easily hopefully. **Semantic changes**: This changes the semantics of execution around global values. Previously a global value would always be counted as mutated if the reference was written, even with the same value. In the implementation here this is no longer the case -- if the value is the same at time of read and the conclusion of execution, the value will not be viewed as mutated. As an example of a program that would exhibit this change in behavior: ```move module 0x42::a; public struct X has key, store { id: UID, x: u64, } public fun update1(x: &mut UID) { let s: &mut X = dynamic_field::borrow_mut(x, 0); assert!(s.x == 10); s.x = 11; s.x = 12; s.x = 10; } public fun update2(x: &mut UID) { let s: &mut X = dynamic_field::borrow_mut(x, 0); assert!(s.x == 10); s.x = 10; } ``` In the previous semantics, the borrowed dynamic field would show as a mutated output of the transaction, in the new semantics it will not show up as mutated as extensionally the value was unchanged. NB: The code in the PR may not be working as future PRs will build on top of this.
… support global references.
…tion to support global references.
dbf5e6d
to
65e799e
Compare
5e307e9
to
63b45c3
Compare
This updates the VM value representation to support global values, and "fingerprinting" of the global values so that they can be properly dirtied at the end of execution.
IMPORTANT
Additional work is needed to make the fingerprinting of global values actually something we'd want to use in prod, but the underlying logic of what a fingerprint is, and how it is computed has been abstracted away into a newtype so we can update this fairly easily hopefully.
Semantic changes
This changes the semantics of execution around global values. Previously a global value would always be counted as mutated if the reference was written, even with the same value. In the implementation here this is no longer the case -- if the value is the same at time of read and the conclusion of execution, the value will not be viewed as mutated. As an example of a program that would exhibit this change in behavior:
In the previous semantics, the borrowed dynamic field would show as a mutated output of the transaction, in the new semantics it will not show up as mutated as extensionally the value was unchanged.
Note however, that for
move_from
andmove_to
operations, we always view this as a dirtying operation. Eventually this logic for global value dirtying will be moved out and will be tracked in the object runtime, but for now we use this implementation to unblock the adapter updates.NB: The code in the PR may not be working as future PRs will build on top of this.