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)

Copy link

trunk-io bot commented Jan 7, 2025

⏱️ 18m total CI duration on this PR
Job Cumulative Duration Recent Runs
rust-move-tests 8m 🟥
rust-cargo-deny 5m 🟩🟩🟩
check-dynamic-deps 2m 🟩🟩🟩
general-lints 1m 🟩🟩🟩
semgrep/ci 1m 🟩🟩🟩
file_change_determinator 31s 🟩🟩🟩
permission-check 9s 🟩🟩🟩
permission-check 7s 🟩🟩🟩
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 +694
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
@wrwg wrwg force-pushed the wrwg/clos_values branch from 6eea07c to 06363e0 Compare January 13, 2025 07:08
@wrwg wrwg force-pushed the wrwg/clos_interp branch from 2ea7443 to 86af06c Compare January 13, 2025 07:08
@wrwg wrwg force-pushed the wrwg/clos_values branch from 06363e0 to 90f0c08 Compare January 14, 2025 02:32
@wrwg wrwg force-pushed the wrwg/clos_interp branch from 86af06c to 9848747 Compare January 14, 2025 02:32
[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.
@@ -43,7 +43,7 @@ pub trait LayoutConverter: LayoutConverterBase {
self.type_to_type_layout_impl(ty, &mut count, 1)
}

/// Converts a runtime type to a fully annotated type layout, containing information about
/// Converts a runtime type to a fully annotated type layout, containing information abountert
Copy link

Choose a reason for hiding this comment

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

There appears to be a typo in the comment - abountert should be about. This affects the readability of the documentation for this type layout conversion function.

Spotted by Graphite Reviewer

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

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