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

Tail call stack flattening #11

Merged
merged 42 commits into from
Mar 27, 2024
Merged

Tail call stack flattening #11

merged 42 commits into from
Mar 27, 2024

Conversation

AjaniBilby
Copy link
Member

Fix the stack issue created by pr #8, where tail calls now aren't fully applicable due to the stack growing with each call.

Implement the return_call statement so that it does a safety check that none of the values parsed to the call are allocated in the local stack (if they are, throw a compilation error). Once that is done, call the function without shifting the stack forward and use the return_call wasm instruction.

This does create some O0 performance penalties, but this can be reduced by making a cache type, using registers where it doesn't write the value straight to the address, instead writing to a local reg first, and only storing to disk when it needs to be composed into a struct or for a value loan
@AjaniBilby AjaniBilby added the enhancement New feature or request label Mar 22, 2024
@AjaniBilby AjaniBilby self-assigned this Mar 22, 2024
@AjaniBilby AjaniBilby changed the title [Draft] Tail call stack flattening Tail call stack flattening Mar 24, 2024
@AjaniBilby AjaniBilby marked this pull request as ready for review March 27, 2024 05:17
@AjaniBilby AjaniBilby merged commit 3a318cb into main Mar 27, 2024
1 check passed
@AjaniBilby AjaniBilby deleted the tail-call-stack-flattening branch March 27, 2024 05:17
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.

1 participant