-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
pulley: Fix interpreter push/pop #9644
pulley: Fix interpreter push/pop #9644
Conversation
Review-wise this is stacked on #9629 |
Subscribe to Label Actioncc @fitzgen
This issue or pull request has been labeled: "pulley"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
* Add stack-overflow checking to `push` and other decrements of `sp`. * Fix the up/down direction of push/pop (`push` goes down, `pop` goes up). * Fix the order of operation sin `push`, first decrement then write. * Move methods to `Interpreter` to use `ControlFlow` more heavily.
47dc174
to
17258bd
Compare
rebased! |
/// `sp -= size_of::<T>(); *sp = val;` | ||
#[must_use] | ||
fn push<T>(&mut self, val: T) -> ControlFlow<Done> { | ||
let new_sp = self.state[XReg::sp].get_ptr::<T>().wrapping_sub(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're switching the direction of growth, is there something that needs to be done to flip where sp
starts at when we create the interpreter state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess MachineState::with_stack
already does that but Pulley was just incorrectly pushing and popping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah I don't believe it was ever the intentional to reverse the order of the stack with respect to native stacks, so I believe this was just a copy/paste error. (you can tell we don't run the interpreter much right now)
push
and other decrements ofsp
.push
goes down,pop
goes up).push
, first decrement then write.Interpreter
to useControlFlow
more heavily.