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

Allocate region variables as "local variables" on previous stack #642

Merged
merged 10 commits into from
Nov 5, 2024

Conversation

serkm
Copy link
Contributor

@serkm serkm commented Oct 14, 2024

@phischu I hate how this turned out.

When allocating into a region, we cannot know the answer type of that region. This makes it impossible to push a regular return address.

As a workaround, variables are allocated with a special return function, that removes the region from the stack. When underflowing a region, we first call this special function, and then return regularly.

Also, this breaks globals, as the first stack has no previous stack.

case Call(_, Ccc(), _, nonglobal, _) =>
C.abort(s"cannot call non-global operand: $nonglobal")
C.abort(s"cannot call non-global operand: $nonglobal") // why not?
Copy link
Collaborator

Choose a reason for hiding this comment

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

@phischu maybe you could discuss this in the meeting briefly?

@@ -385,7 +349,7 @@ object Transformer {
emit(callLabel(returnAddress, values.map(transform)))
RetVoid()

case machine.NewStack(variable, prompt, frame, rest) =>
case machine.NewStack(variable, prompt, frame, isRegion, rest) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

will this flag go away when we allocate regions directly on the stack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we need to know whether we are returning from a region.

@serkm
Copy link
Contributor Author

serkm commented Oct 22, 2024

The last commit depends on #651

b-studios added a commit that referenced this pull request Oct 23, 2024
This enables automatic growing of LLVM's stack once the end is reached
(or memory larger than the remaining space is allocated).

We can now have much smaller stack sizes than before. For now, I've set
the previous 256M stacks to 1KB (which, after initial tests, seems
fine).

Due to some code repetition I wanted to merge the growing logic of
regions with this. I've reverted my attempts since #642 removes the
duplicated code anyway.

---------

Co-authored-by: Jonathan Immanuel Brachthäuser <jonathan@b-studios.de>
Co-authored-by: Philipp Schuster <philipp.schuster@uni-tuebingen.de>
Copy link
Collaborator

@phischu phischu left a comment

Choose a reason for hiding this comment

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

Nice, so much code was deleted.

@phischu phischu merged commit 6cd49d2 into effekt-lang:master Nov 5, 2024
2 checks passed
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.

3 participants