Skip to content
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

core/vm: use stack arena #30362

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

core/vm: use stack arena #30362

wants to merge 5 commits into from

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Aug 28, 2024

OBS, wip, this is nowhere near ready for merging

This is an experimental stack layout, using an underlying arena of uint256.Int. The actual stacks that are used during execution uses the stack-arena for storage.

At this point, I'm still experimenting with who shoud hold what, e.g. if both the arena and stack-instances need to keep track of top. Right now the arena has a top, and the stacks have a bottom and a size.

I have also not implemented the growing of the arena. Possibly, there will be an ensureCapacity method which ensures that there's room for at least 1 more item (any evm operation grows the stack at most by 1) - and the methods that expand the stack by 1 are the only ones that need ever invoke it.

Since the elements are uint256.Int, we should avoid giving out pointers to the elements. The peek method does so, which is "unsafe", but the peek was only ever meant for evm operations to modify a stack item directly, without popping/pushing. The peeked references are not held more than a very brief time, so it should be ok.

Posting it here for eyes / suggestions / discussions.

@holiman holiman changed the title Bigstack core/vm: use stack arena Aug 28, 2024
@holiman holiman force-pushed the bigstack branch 2 times, most recently from 582d71e to f769c24 Compare August 28, 2024 11:52
@holiman holiman force-pushed the bigstack branch 3 times, most recently from ddfd15e to 33e034c Compare August 28, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant