-
Notifications
You must be signed in to change notification settings - Fork 158
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
Stack depth management for CALL blocks #403
Conversation
f6a1c1f
to
31f825e
Compare
41ddd96
to
9ef0c77
Compare
9ef0c77
to
76af515
Compare
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.
Looks good! I left a few small things inline related to clarity
// if last_row_addr is ZERO, any rows in the overflow table are not accessible from the | ||
// current context. Thus, we should not be able to remove them. | ||
debug_assert_ne!( | ||
self.last_row_addr, ZERO, | ||
"overflow table is empty in the current context" | ||
); |
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.
given that removing an overflow row when the table is actually empty will cause a failure, I wonder if this should be a regular assert instead of debug_assert
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.
This should actually never happen under normal execution because we call Overflow::pop()
only from Stack::shift_left()
function. And there, we remove an item from the overflow table only if the stack depth is > 16.
76af515
to
62c078c
Compare
This PR implements management of stack depth for
CALL
code blocks. The rules are as follows:CALL
operation is executed, stack depth is set to 16 (the overflow table stays unchanged). This means that the callee function has access only the top 16 stack items of the caller.CALL
block is ended, stack depth is set to its pre-call value. We also need to ensure that the callee did not leave any extra items in the overflow table. To do this, we enforce that stack depth must be exactly 16 when aCALL
block ends.This PR includes the following:
MIN_STACK_DEPTH
->STACK_TOP_SIZE
), and fixing a couple of trace generation bugs related to population of stack helper registers.stack.start_context()
andstack.restore_context()
methods to facilitate starting/ending of execution contexts within a stack.Process
struct for test purposes was updated to ensure that during tests user operations are never executed atclk=0
.CALL
block starts/ends execution. Also, components related to block stack table management were updated.This PR does not include updates to the docs describing changes to constraints etc.