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

Feature: New memory layout #133

Merged
merged 4 commits into from
Apr 16, 2024
Merged

Feature: New memory layout #133

merged 4 commits into from
Apr 16, 2024

Conversation

brendanfh
Copy link
Collaborator

This pull request alters the memory layout of a typical Onyx program, specifically how the stack operates. Up until this point, the stack grew up towards the maximum address, i.e. setting up the call frame involved adding to the stack pointer. This was sufficient, but as I am looking to the future of interoperating with other libraries compiled to WASM, I noticed that all other languages/compilers have the stack growing down towards 0. While this choice is largely arbitrary, it makes more sense to make Onyx conform to this memory model.

In short, the memory went from looking like this:

| globals / static data | stack -->   ...  |  heap -->  

To this:

| ...  <-- stack | globals / static data | heap -->

Aside from being compatible with other languages, this model has one great benefit: if the stack is overflowed, the program will crash, instead of blinding overwriting the heap and corrupting memory.

@brendanfh brendanfh added the enhancement New feature or request label Apr 4, 2024
@brendanfh brendanfh added this to the v0.1.11 milestone Apr 4, 2024
@brendanfh brendanfh self-assigned this Apr 4, 2024
Stack first is not only the new default, but placing the stack after the
global data largely does not make sense anymore.
@brendanfh brendanfh mentioned this pull request Apr 6, 2024
10 tasks
@brendanfh brendanfh merged commit 772a186 into master Apr 16, 2024
15 checks passed
@brendanfh brendanfh deleted the feature/change-memory-layout branch April 16, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant