Skip to content

Commit

Permalink
Fix stack traces for future instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickpeterse committed Sep 20, 2022
1 parent 9cee2ea commit 9dd29cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions bytecode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,15 @@ impl Opcode {
Opcode::FuturePoll => 2,
}
}

pub fn rewind_before_call(self) -> bool {
matches!(
self,
Opcode::BuiltinFunctionCall
| Opcode::FutureGet
| Opcode::FutureGetFor
)
}
}

/// A fixed-width VM instruction.
Expand Down
3 changes: 1 addition & 2 deletions vm/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::indexes::{FieldIndex, MethodIndex};
use crate::location_table::Location;
use crate::mem::{allocate, ClassPointer, Header, MethodPointer, Pointer};
use crate::scheduler::timeouts::Timeout;
use bytecode::Opcode;
use std::alloc::{alloc, dealloc, handle_alloc_error, Layout};
use std::collections::VecDeque;
use std::mem::{align_of, size_of, swap};
Expand Down Expand Up @@ -763,7 +762,7 @@ impl Process {
// _after_ the call. For built-in function calls this isn't the
// case, as we store the current index instead so the call can
// be retried (e.g. when a socket operation) would block.
if index > 0 && ins.opcode != Opcode::BuiltinFunctionCall {
if index > 0 && !ins.opcode.rewind_before_call() {
index -= 1;
}

Expand Down

0 comments on commit 9dd29cd

Please sign in to comment.