Skip to content

Commit

Permalink
[vm rewrite] Swap to a more step-driven interpreter (#19219)
Browse files Browse the repository at this point in the history
## Description 

This splits up the interpreter to be more step-by-step than the previous
loop with control flags approach. It also closes some of the circuit on
ArenaPointer usage.

The `move-execution` changes are just due to `cargo fmt --all`.

## Test plan 

All tests still pass

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
cgswords authored Sep 12, 2024
1 parent 0e28d09 commit ca4297c
Show file tree
Hide file tree
Showing 12 changed files with 1,815 additions and 1,538 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
Command `sandbox publish`:
Command `sandbox run storage/0x0000000000000000000000000000000000000000000000000000000000000042/modules/print_stack_trace.mv print_stack_trace --dry-run`:
Call Stack:
[0] 0000000000000000000000000000000000000000000000000000000000000042::print_stack_trace::print_stack_trace
[0] 0000000000000000000000000000000000000000000000000000000000000007::M::sum

Code:
[1] LdU64(2)
[2] Lt
[3] BrFalse(8)
> [4] Call(print_stack_trace)
[5] MoveLoc(0)
[6] StLoc(1)
[7] Branch(15)

Locals:
[0] 1
[1] -


[1] 0000000000000000000000000000000000000000000000000000000000000042::print_stack_trace::print_stack_trace

Code:
[10] LdU64(1)
Expand All @@ -18,7 +34,7 @@ Call Stack:
[2] -


[1] 0000000000000000000000000000000000000000000000000000000000000007::N::foo<bool, u64>
[2] 0000000000000000000000000000000000000000000000000000000000000007::N::foo<bool, u64>

Code:
[2] MutBorrowLoc(0)
Expand All @@ -35,7 +51,7 @@ Call Stack:
[2] -


[2] 0000000000000000000000000000000000000000000000000000000000000007::M::sum
[3] 0000000000000000000000000000000000000000000000000000000000000007::M::sum

Code:
[9] MoveLoc(0)
Expand All @@ -51,7 +67,7 @@ Call Stack:
[1] -


[3] 0000000000000000000000000000000000000000000000000000000000000007::M::sum
[4] 0000000000000000000000000000000000000000000000000000000000000007::M::sum

Code:
[9] MoveLoc(0)
Expand All @@ -67,7 +83,7 @@ Call Stack:
[1] -


[4] 0000000000000000000000000000000000000000000000000000000000000007::M::sum
[5] 0000000000000000000000000000000000000000000000000000000000000007::M::sum

Code:
[9] MoveLoc(0)
Expand All @@ -90,7 +106,23 @@ Operand Stack:

[debug] 10
Call Stack:
[0] 0000000000000000000000000000000000000000000000000000000000000042::print_stack_trace::print_stack_trace
[0] 0000000000000000000000000000000000000000000000000000000000000007::M::sum

Code:
[1] LdU64(2)
[2] Lt
[3] BrFalse(8)
> [4] Call(print_stack_trace)
[5] MoveLoc(0)
[6] StLoc(1)
[7] Branch(15)

Locals:
[0] 1
[1] -


[1] 0000000000000000000000000000000000000000000000000000000000000042::print_stack_trace::print_stack_trace

Code:
[16] CallGeneric(1)
Expand All @@ -106,7 +138,7 @@ Call Stack:
[2] 10


[1] 0000000000000000000000000000000000000000000000000000000000000007::N::foo<u8, bool>
[2] 0000000000000000000000000000000000000000000000000000000000000007::N::foo<u8, bool>

Code:
[2] MutBorrowLoc(0)
Expand All @@ -123,7 +155,7 @@ Call Stack:
[2] -


[2] 0000000000000000000000000000000000000000000000000000000000000007::M::sum
[3] 0000000000000000000000000000000000000000000000000000000000000007::M::sum

Code:
[9] MoveLoc(0)
Expand All @@ -139,7 +171,7 @@ Call Stack:
[1] -


[3] 0000000000000000000000000000000000000000000000000000000000000007::M::sum
[4] 0000000000000000000000000000000000000000000000000000000000000007::M::sum

Code:
[9] MoveLoc(0)
Expand All @@ -155,7 +187,7 @@ Call Stack:
[1] -


[4] 0000000000000000000000000000000000000000000000000000000000000007::M::sum
[5] 0000000000000000000000000000000000000000000000000000000000000007::M::sum

Code:
[9] MoveLoc(0)
Expand Down
6 changes: 3 additions & 3 deletions external-crates/move/crates/move-vm-runtime/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
interpreter::Interpreter,
interpreter::state::MachineState,
loader::{
ast::{Bytecode, Function},
Loader,
Expand Down Expand Up @@ -134,7 +134,7 @@ impl DebugContext {
function_desc: &Function,
locals: &Locals,
pc: u16,
interp: &Interpreter,
interp: &MachineState,
resolver: &Loader,
) {
let function_string = function_desc.pretty_short_string();
Expand Down Expand Up @@ -168,7 +168,7 @@ impl DebugContext {
pc: u16,
instr: &Bytecode,
resolver: &Loader,
interp: &Interpreter,
interp: &MachineState,
) {
let instr_string = format!("{:?}", instr);
let function_string = function_desc.pretty_short_string();
Expand Down
Loading

0 comments on commit ca4297c

Please sign in to comment.