feat(vm): reset origin id before calling <origin,ptr,atom>
This commit is contained in:
parent
7580ba28bb
commit
9c0ad2fa15
|
@ -98,6 +98,11 @@ impl Pointer {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_origin(&mut self, origin: u16) {
|
||||
self.0[8..10].copy_from_slice(&origin.to_be_bytes());
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn origin(&self) -> u16 {
|
||||
u16::from_be_bytes(self.0[8..10].try_into().unwrap())
|
||||
|
|
|
@ -136,7 +136,7 @@ impl Process {
|
|||
tracing::error!("`call-r` invoked on empty stack @ {}", previptr);
|
||||
break;
|
||||
}
|
||||
Some(StackEntValue::Pointer(wp)) => {
|
||||
Some(StackEntValue::Pointer(mut wp)) => {
|
||||
let ssl = self.stack.len();
|
||||
let mut args = self.stack.drain(ssl - usize::from(arity)..).collect();
|
||||
let origin_id = usize::from(wp.origin());
|
||||
|
@ -144,6 +144,7 @@ impl Process {
|
|||
match origin {
|
||||
Ok(origin) => match origin.as_ref() {
|
||||
Some(origin) => {
|
||||
wp.set_origin(0);
|
||||
self.instrp = origin.call(&wp, &atom, &mut args);
|
||||
self.stack.extend(args);
|
||||
}
|
||||
|
|
1
docs/TODO.md
Normal file
1
docs/TODO.md
Normal file
|
@ -0,0 +1 @@
|
|||
* reduce stack item size (see `fogtix_vm::tests::stack_item_size`)
|
Loading…
Reference in a new issue