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

Paged memory model #489

Closed
wants to merge 1 commit into from
Closed

Paged memory model #489

wants to merge 1 commit into from

Conversation

Dentosal
Copy link
Member

@Dentosal Dentosal commented May 25, 2023

TODO:

  • Document how gas metering works
  • Add panic conditions to memory-allocating instructions

Every time the VM runs, a single monolithic memory of size `VM_MAX_RAM` bytes is allocated, indexed by individual byte. A stack and heap memory model is used, allowing for dynamic memory allocation in higher-level languages. The stack begins at `0` and grows upward. The heap begins at `VM_MAX_RAM - 1` and grows downward.
The VM has `VM_MAX_RAM` bytes of ram, indexed by individual byte. A stack and heap memory model is used, allowing for dynamic memory allocation in higher-level languages. The stack begins at `0` and grows upward. The heap begins at `VM_MAX_RAM - 1` and grows downward. Unused memory is initialized to zero.

Memory is gas-metered by usage. It's allocated in 16 KiB pages, which are transparently creted when either stack or heap grows beyond the current page. Both stack and heap are contiguous, and pages for those are allocated separately. The stack and heap are not allowed to overlap, but it's possible for them to share the last available page of memory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dentosal Fix "creted" typo.

@Dentosal
Copy link
Member Author

Dentosal commented Jun 5, 2023

This is likely not going to happen

@Dentosal Dentosal closed this Jun 5, 2023
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.

2 participants