Skip to content
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

Open
wants to merge 1 commit into
base: wrwg/clos_values
Choose a base branch
from
Open

Conversation

wrwg
Copy link
Contributor

@wrwg wrwg commented Jan 7, 2025

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

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

[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.
Copy link

trunk-io bot commented Jan 7, 2025

⏱️ 11m total CI duration on this PR
Job Cumulative Duration Recent Runs
rust-move-tests 8m 🟥
rust-cargo-deny 2m 🟩
check-dynamic-deps 39s 🟩
general-lints 25s 🟩
semgrep/ci 21s 🟩
file_change_determinator 10s 🟩
permission-check 4s 🟩
permission-check 2s 🟩
check-branch-prefix 1s 🟩

settingsfeedbackdocs ⋅ learn more about trunk.io

Copy link
Contributor Author

wrwg commented Jan 7, 2025


let ty_args = function.ty_args();
if RTTCheck::should_perform_checks() {
if RTTCheck::should_perform_checks() && is_captured {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change if RTTCheck::should_perform_checks() && is_captured { to if RTTCheck::should_perform_checks() && !is_captured { since type checking should be performed on stack operands, not captured arguments which were already verified

Spotted by Graphite Reviewer (based on CI logs)

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines 499 to +510
let num_param_tys = function.param_tys().len();

for i in 0..num_param_tys {
locals.store_loc(
num_param_tys - i - 1,
self.operand_stack.pop()?,
loader.vm_config().check_invariant_in_swap_loc,
)?;
for i in (0..num_param_tys).rev() {
let is_captured = mask.is_captured(i);
let value = if is_captured {
captured.pop().ok_or_else(|| {
PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR)
.with_message("inconsistent closure mask".to_string())
})?
} else {
self.operand_stack.pop()?
};
locals.store_loc(i, value, loader.vm_config().check_invariant_in_swap_loc)?;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix argument ordering mismatch by using captured.remove(0) instead of pop() to maintain consistent argument ordering between regular and captured arguments. This ensures arguments are processed in the same order regardless of whether they are captured or not.

Spotted by Graphite Reviewer (based on CI logs)

Is this helpful? React 👍 or 👎 to let us know.

@wrwg wrwg marked this pull request as ready for review January 8, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant