-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[move-vm][closures] Interpreter #15680
base: wrwg/clos_values
Are you sure you want to change the base?
Conversation
⏱️ 18m total CI duration on this PR
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
6eea07c
to
06363e0
Compare
2ea7443
to
86af06c
Compare
06363e0
to
90f0c08
Compare
86af06c
to
9848747
Compare
90f0c08
to
4ccfa58
Compare
9848747
to
0547a60
Compare
third_party/move/move-vm/runtime/src/storage/ty_layout_converter.rs
Outdated
Show resolved
Hide resolved
4ccfa58
to
c47a82f
Compare
44d692c
to
0ff52e9
Compare
9359cfa
to
129ffe7
Compare
0ff52e9
to
a208441
Compare
129ffe7
to
474593c
Compare
ba7ac48
to
b4b6105
Compare
)?; | ||
}, | ||
ExitCode::CallClosure(_sig_idx) => { |
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.
How do we plan to charge gas for dependencies? In the current system, you should call check_dependencies_and_charge_gas
for the function's module ID, to ensure that the modules loaded with closure are charged for. You probably should do it after popping the closure from thr stack, since you know function's name and module.
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.
Also, you should charge for ty tags (see my recent PR for that which you approved)
// TODO(#15664): runtime checks. We should verify that the popped | ||
// argument types match the function. | ||
let function = resolver | ||
.build_loaded_function_from_handle_and_ty_args(*fh_idx, vec![])?; |
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.
This will load the function if it is defined outside of this module, we should be charging gas for module loading here as well.
@@ -593,21 +676,29 @@ impl InterpreterImpl { | |||
loader: &Loader, | |||
function: Rc<LoadedFunction>, | |||
frame_cache: Rc<RefCell<FrameTypeCache>>, | |||
mask: ClosureMask, |
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.
I think it would be nicer to have frame setups for closures being completely separate, also no need to pass empty mask and empty captured args everywhere. Whatever is here inside can be factored out into helpers.
474593c
to
bb8390f
Compare
b4b6105
to
2a7face
Compare
bb8390f
to
24a5460
Compare
2a7face
to
83a174e
Compare
24a5460
to
e6560c5
Compare
83a174e
to
f48e6f6
Compare
@@ -2198,6 +2310,42 @@ impl Frame { | |||
.operand_stack | |||
.push(reference.test_variant(info.variant)?)?; | |||
}, | |||
Bytecode::PackClosure(fh_idx, mask) => { | |||
// TODO(#15664): runtime checks. We should verify that the popped |
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.
BTW I think @ziaptos refactored the runtime checks so that you wouldn't need to add the checks in the core interpretation loop.
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.
self.operand_stack.pop()?, | ||
loader.vm_config().check_invariant_in_swap_loc, | ||
)?; | ||
for i in (0..num_param_tys).rev() { |
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.
You could probably use the same helper function you had in ClosureMask to avoid the for loops here? Simialar to call_native
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.
Core VM logics seem pretty clean to me. I would want to get another eye from @vgao1995 on the gas semantics just so we are charging call instructions properly?
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.
third_party/move/move-vm/runtime/src/runtime_type_checks.rs
is the location where paranoid mode is checked. Was wondering if we should make the checks to be nil op if you haven't implemented them yet and don't plan to implement it in this PR because the check should have behaved differently when you switch off the flag
e6560c5
to
b3492b5
Compare
f48e6f6
to
fd6aabd
Compare
b3492b5
to
c668c04
Compare
ff41d73
to
9848bce
Compare
90f4c9a
to
3864e40
Compare
9848bce
to
2cce955
Compare
[PR 5/n vm closures] This closes the loop, putting the pieces together to implement the closure logic in the interpreter loop. They are some paranoid checks still missing which are marked in the code.
3864e40
to
cfde21d
Compare
2cce955
to
57afe25
Compare
Description
[PR 5/n vm closures]
This closes the loop, putting the pieces together to implement the closure logic in the interpreter loop.
They are some paranoid checks still missing which are marked in the code.
How Has This Been Tested?
Testing postponed until e2e tests are possible
Type of Change
Which Components or Systems Does This Change Impact?